Why some famous programs are always using print [closed] Why some famous programs are always using print [closed] wordpress wordpress

Why some famous programs are always using print [closed]


In all actuality, Echo and Print differ based on how they are structured. Print returns a value much like a normal function would. But despite common belief, Print is not a function, as we can see by the fact that it doesn’t require parenthesis to work (Not to be confused with Printf). Print and Echo are actually both called language constructs, although this isn’t to say that we can’t make Print act like a function.

You can find some more reference here :

http://www.learnphponline.com/php-basics/php-echo-vs-print

Not entirely complete, though. Print can be used as part of complex constructs, such as

($b) ? printTrue” : printFalse”;

whereas Echo cannot. Also, if you want to use error output (@print”Test”;) you cannot use echo.Otherwise – good info.


There is nothing in the PHP docs to support this claim. However, a key difference between the two is that echo does not return a value and print does. So one could make an argument that echo is therefore more efficient.

Checkout the PHP Benchmark for more information about echo vs print and other interesting comparisons.

In the end, such things boil down to personal convention. Whatever efficiency gained from using echo over print is more than likely trivial relative to other areas of the code.


In performance tests I have seen no difference in speed between print and echo in PHP so they are interchangeable. Really it's personal preference. In the wild I've seen strictly PHP programmers stick to echo and multi-lingual programmers (if that's a phrase) use either.