In this chapter we will discuss the usage of the two statements in detail and demonstrate how to use echo and print in examples.
PHP echo and print statements
The difference between echo and print:
echo - can output one or more strings
print - only allows one string to be output, and the return value is always 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 with parentheses: echo or echo().
Display string
The following example demonstrates how to use the echo command to output a string (the string can contain HTML tags):
print is also a language structure that can use parentheses or not: print or print ().
Display string
The following example demonstrates how to use the print command to output a string (the string can contain HTML tags):
The above introduces the PHP 5 echo and print statements, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.