
|
|
|||
Introduction to PHP ProgrammingBy PHP Catalyst2007-11-19
Printing Strings in PHP In this section, we will learn to print strings. Also, see how to print values of variables along with strings, with help of some examples. Simple PrintingSimple printing in PHP means that we will assign a string to a variable and print it's value in the output. Let us begin with this simple example.
<?php In the above example, we used a backslash when we enclosed the string 'Let's Rock' in single quote. This is called escaping. This is essential when you want to avoid PHP from processing certain portion of code. For example, if you can put \ in front of variable $string in your echo statements to avoid printing the value of the variable, such as \$string. Sometimes, you may have to put more backslashes, like \\\$string Printing VariablesWe will now look at assigning a string to a variable and printing it's value as an output. See this example:
<?php You must try to experiment with the above code and modify it to see how it works. That will be a great learning experiencing for you! Let's also take a look at some built-in constructs of PHP that we can make use of to print one or more strings. SOme of these are:
These built-in constructs can be used in the same way we use 'echo' to print strings. We will now move on to our next section on String Comparison Tutorial Pages: » What can I do with PHP? » Popoular Features of PHP » Basics of PHP » Variables in PHP » Data Types in PHP » Expressions and Operators » Control Structures in PHP » Functions in PHP » Declaring Functions in PHP » Scope of a Variable » Built-in Functions in PHP » Handling Strings in PHP » Printing Strings in PHP » String Comparisons in PHP » Manipulating Strings in PHP » Arrays in PHP » Types of Arrays in PHP » Creating Arrays in PHP » Array Operations in PHP |
||||
| About the NetVisits, Inc Network | Write For Us | Advertise Copyright ©2007 NetVisits, Inc Network. All Rights Reserved. Privacy Policy. |
Visit other NetVisits, Inc. sites: |