Sometimes when we use the PHP language to encode a situation where we can output one or more strings, what do we do when we encounter this situation? At this point we need to use the function echo () of PHP. Next, this article will talk about the use of the Echo () function in PHP. Take a look at the specific example of the Echo () function.
Definition and usage
The PHP function echo () outputs one or more strings.
Grammar
Echo (Strings)
Parameter description
Strings must have. One or more strings to send to the output.
Hints and Notes
Note: Echo () is not actually a function, but rather a language structure, so you do not need to use parentheses on it. However, if you want to pass one or more arguments to echo (), a parse error occurs when you use parentheses.
Tip: the Echo () function is a little faster than the print () function.
Tip: The PHP function echo () can use the simplified syntax. As shown in the following example:
1.echo Output Scalar
PHP echo 123adb;//output correct echo 123abd;//correct echo "123adb";//correct ?>
2, PHP function echo () output variable, constant
PHP $a = "123456"; echo $a; Correct echo "< span>br>"; echo "$a"; Correct echo "< span>br>"; echo $a;//Incorrect echo "< span>br>"; echo abcdef; Can be displayed correctly, but it is strongly not recommended because there are many special symbols that do not display correctly. echo "< span>br>"; Echo <abd>; For example, with a pointed, you can not use, you may go to the front of the comments to try will not error. echo "< span>br>"; $b =10; echo $b +10; Display echo "< span>br>"; echo "$b +10"; echo "< span>br>"; echo "The result is:". " $b "; The effect of these two formulations is the same. echo "< span>br>"; echo "The result is: $b"; The effect of these two formulations is the same. ?>
echo "" and the PHP function echo () are different, double quotation marks when the variable is escaped with a particular symbol, the addition of single quotation marks will not be escaped, the single quotation marks the direct output of the symbol, so that the single quotation marks than double quotation marks a little faster. Don't use double quotation marks when you can.