top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is difference between echo() and print() ?

+1 vote
364 views
What is difference between echo() and print() ?
posted Jun 4, 2014 by Karamjeet Singh

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote

Echo can accept multiple expressions while print cannot. With respect to performance echo is faster than print since it does not return a value. Print returns 1 or 0 depending on the success.

Speed of echo vs print in PHP
The speed of both echo and print statements in PHP is roughly the same. Using one over the other is not likely to yield any performance improvement in your application. Theoretically, echo is more efficient because it does not return any value.

Parameters and syntax of print vs echo
When used with parentheses (like a function call), both print and echo take only 1 argument. For example, echo("Don't panic!");
However, when used without parentheses, echo can take several arguments e.g.
echo "Don't","panic","!",42;

answer Jun 5, 2014 by Vrije Mani Upadhyay
0 votes

1.Keyword echo can output multiple strings but print can only output one string.
2.print() has a return value of true or false whereas echo has a void return type.
3.echo() is slightly faster than print.

answer Jun 5, 2014 by Rahul Mahajan
...