Echo and Print differences:
echo-can output one or more strings
Print-allows only one string to be output, with a total return value of 1
tip:The echo output is faster than print, ECHO has no return value, and print has a return value of 1.
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 "
Show variables
The following example shows how to use the echo command to output variables and strings:
<?php$txt1= "Learn PHP"; $txt 2= "w3cschool.cc"; $cars =array ("Volvo", "BMW", "Toyota"), Echo $txt 1;echo "<br>"; echo "Study PHP at $txt 2", echo "My car is a {$cars [0]}";? >
Print StatementPrint is also a language structure, you can use parentheses, or you can use no parentheses: Print or print ().
Display string
The following example shows how to use the Print command to output a string (the string can contain HTML tags):
<?phpprint "
Show variables
The following example shows how to use the Print command to output variables and strings:
<?php$txt1= "Learn PHP"; $txt 2= "w3cschool.cc"; $cars =array ("Volvo", "BMW", "Toyota");p rint $txt 1;print "<br>" ;p rint "Study PHP at $txt 2";p rint "My car is a {$cars [0]}";? >
php_002 Echo and Print