PDA

View Full Version : what is the difference between echo and print command in php?



iammanisha
04-12-2017, 10:15 AM
what is the difference between echo and print command in php?

michral
06-24-2017, 09:20 AM
PHP*echo*and*print*both are PHP Statement.
Both are used to display the output in PHP.
echo
1. echo is a statement i.e used to display the output. it can be used with parentheses echo or without parentheses echo.
2. echo can pass multiple string separated as ( , )
3. echo doesn’t return any value
4. echo is faster then print


Example:

<?php
$name="Ravi";
echo $name;
//or
echo ($name);
?>


Print
1. Print is also a statement i.e used to display the output. it can be used with parentheses print( ) or without parentheses print.
2. using print can doesn’t pass multiple argument
3. print always return 1
4. it is slower than echo

Example:

<?php
$name="Ravi";
print $name;
//or
print ($name);
?>