Difference between echo and print in PHP

This article is created to differentiate the two famous keywords or statements, that are:

PHP echo Vs print

echo print
Takes more than one parameters Takes only one parameter
Does not return any value Always returns 1
Can not be used as an expression Can be used as an expression
Little faster than print Little slower than echo

PHP echo Vs print Example

   print "codescracker";
   echo "<hr>";
   echo "codes", "cracker";
   echo "<hr>";
   $x = 120;
   $x ? print "'x' is defined" : print "'x' is not defined";

The output of above PHP example, is:

difference between echo and print php

For details about any of the two or both the two statements, refer to its separate tutorial.

PHP Online Test

« Previous Tutorial Next Tutorial »