Friday 29 November 2013

Difference between echo and print in PHP

Difference between echo and print in PHP:

There are some differences between echo and print:

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

    We can use both echo and print statements as echo() , print().
Tip: echo is very faster compared to print as echo does not return any value

Here is an example:

<?php

echo "Hello world";
echo "PHP","is","a scripting","language"; // it prints multiple parameters.

print "Hello world";
print "PHP is a scripting Language";

?>

I welcome any comments. #Anbu