This article introduces to you about the PHP5 in the Echo statement and print statements are different, there is a certain reference value, the need for friends can refer to, I hope to help you.
PHP Echo and Print statements
Echo and Print differences:
echo-Can output one or more strings, no return value
Print- allows only one string to be output, with a Total return value of 1
tip:echo outputs faster than print , ECHO has no return value, and print has a return value of 1.
PHP Echo Statement
Echo is a language structure that can be used without parentheses or parentheses: Echo or Echo ().
Display string
The following example shows how to use the echo command to output a string (the string can contain HTML tags):
<?phpecho "
How to output variables and strings
<?php$txt1= "Learning php", $txt 2= "Liuhang", $cars =array ("Volvo", "BMW", "Toyota"); echo $txt 1;echo "<br>", echo "$txt 2 love to learn PHP", echo "<br>", echo "the brand of my car is {$cars [0]}";? >
Print statement
In addition to outputting only one string at a time, it is no different from Echo.
<?php$txt1= "Learning php", $txt 2= "Liuhang", $cars =array ("Volvo", "BMW", "Toyota"); Print $txt 1;print "<br>;p rint" $txt 2 love to learn PHP ";p rint" <br> ";p rint" My car brand is {$cars [0]} ";? >
Related articles recommended:
Example code for _get methods and _set method access methods in PHP
The use of the Echo () function in PHP (with code)