Ok, this has been bugging me for a while and I just have to ask. What is the major difference between print and echo? Often times you see them used interchangeably, and some people swear by one over the other. What is the huge difference between the two?
04/24/2009 - 09:29
The main two differences are going to be a marginal speed increase using
echoand the fact thatprintacts like a function.The reason
echois faster is because it does not return any value, as apposed toprintwhich always returns1.The
printfunction acts like a function which means it can be used in complex expressions. Something like:Where as
echocan not be used in that way.You can also check out more over at http://www.faqts.com/knowledge_base/view.phtml/aid/1/fid/40
04/24/2009 - 09:46
That's pretty informative. Thanks a bunch.
08/03/2009 - 03:25
Benchmarking code to view the comparison can be found at:
http://coffeeandpaste.blogspot.com/2009/07/php-echo-vs-print.html
Add Comment
[language] [/language]
Examples:
[javascript] [/javascript]
[actionscript] [/actionscript]
[csharp] [/csharp]
See here for supported languages.
Javascript must be enabled to submit anonymous comments - or you can login.