I've read somewhere, do not remember where now, that echo
is a more efficient way of outputting data then print
.
Why do many famous software packages and frameworks, like WordPress and Drupal, like print so much? Is there any special reason behind that, or just a habit?
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) ? print “True” : print “False”;
whereas Echo cannot. Also, if you want to use error output (@print”Test”;) you cannot use echo. Otherwise – good info.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With