echo and print Statements in PHP

differences between echo and print:

      echo - can output one or more strings.
      print - can only output one string, and returns always 1.

PHP echo Statement

     echo is a language construct, and can be used with or without parentheses: echo or echo().


Example :

<?php
echo "Hello world <br>";
$txt="PHP";
echo $txt;
?>

PHP print Statement

Print is also a language construct, and can be used with or without parentheses: print or print().

Example :

<?php
print "Hello world <br>";
$txt="PHP";
print $txt;
?>

Comments