Difference between PHP echo() and PHP print()?
Echo and Print are almost same both are used to display the output but there is minor difference between these two is that :
Echo is more faster than print.
PHP print() has a return value , whereas PHP echo() has a void return type.
PHP echo() and PHP print() both are different. print() return value on the other hand echo() not return any value.
Echo is a constructor and Print is a function.
In PHP, echo is not a function but a language construct, whereas print is not a function but a language construct. However, it behaves like a function in that it returns a value.
One of the most important difference in between these : Echo can take multiple values whereas print cannot, it take only one parameter.
We take a example it became easy for you to understand this.
Firstly taking a example of php echo in php:
<title> echo program</title>
echo’cascading’,’style’,’sheet';
//one or more strings
Now we take a Example of print:
<title> print program</title>
<?phpprint ‘cascading’,’style’,’sheet';?>
: syntax error, unexpected ‘,’ on line number 7, because print only display one string.
Now we take again print Example having one string:
<title>print program</title>
<>print ‘name';//one or more strings