What is the difference between print and echo in php?
The echo and print are basically the same functions, display output data on the screen. However, there are some minor differences between the two such as:
Echo | |
---|---|
It has no return value. | It has a return value of 1, hence can be used in expressions. |
It can work with multiple parameters. | It can function with only one argument at a time. |
It is a bit faster than Print | A bit slower than Print. |
Here’s an example of each Echo and Print to clearly demonstrate their proper usage:
BY Best Interview Question ON 05 May 2020
Example
Echo
echo "PHP is Fun!";
print "PHP coding is Fun!";