Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why some famous programs are always using print [closed]

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?

like image 801
zhuanzhou Avatar asked Jul 03 '11 02:07

zhuanzhou


1 Answers

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.

like image 127
Pheonix Avatar answered Oct 06 '22 07:10

Pheonix