What is the use of 'print' in php?

The use of 'print' and echo in PHP:

In speed. echo is marginally faster than Print() since it doesn't set a return value. echo can hold multiple parameters.ex.
echo 'foo', 'bar'; // Concatenates the 2 strings

Expression. Print () behaves like a function and return such as:
$ret = print "Hello World"; And $ret will be 1. That means that print can be used as part
of a more complex expression where echo cannot. Printf() has ability to accept only one parameter.ex.

print('foo', 'bar'); // Fatal error
 
Back
Top