Home > Article > Backend Development > What is the difference between echo and print in PHP?
What is the difference between echo and print in PHP?
1. Echo can accept N string type parameters, while print can only receive 1 string type parameter;
2. Echo has no return value, and print does. The return value is always 1 of type int.
The two are similar:
echo and print are both language structures (official documents explain it as language construct);
echo and print are both Used to output strings;
When there is only one parameter at the same time, the parentheses (parenthesis) after echo and print are optional, that is: echo ($argument1) is equivalent to echo $argument1, print(argument) is equivalent to print argument;
echo and print will convert the parameters and try to convert them to string type before outputting.
Recommended tutorial: "PHP"
The above is the detailed content of What is the difference between echo and print in PHP?. For more information, please follow other related articles on the PHP Chinese website!