php echo and print difference

Written By Naveen on Tuesday, November 29, 2011 | 4:38 AM


echo
 - Is a command only.
 - Faster than print
 - It can print multiple values.
  Example:
 <?php
  echo 1,2,3,4;
  echo $name,$email,$phone;
 ?>

print
 - Is a function.
 - It will return true(1) or false(0) or some values.
 - It can print only one value.
    Example:
    <?php
    print 1;
    print $name;
    if(print(1)){
         echo "print returned true";
    }
    ?>



No comments:

Post a Comment