Differences Between Two Printing Commands In PHP
submitted: Jul 13th 2008 |
by: ZacharySchuessler |
Total views: 1 |
Word Count: 456 |
|
PHP is a highly robust language- one that has attracted web developers from all across the world to take place in the web application craze that's been raging. Getting the most out of the language means understanding it- and something most developers don't know is simple things such as the difference between Echo and Print.
Echo and Print are both commands used to display something to the browser. Both are used in similar structure, and both are identical in output. So what, then, is the use for having two commands that appear to do the exact same thing?
Print is actually something more of a function, as it can be enclosed in brackets. Echo lacks this ability, but then again, there is almost never a need to do so. In reality, having this ability is something that even those who have seen it all in PHP likely won't need to make use of. This just adds more confusion to the topic than what was previously apparent.
Speed is a major concern in web applications. This holds true with the Print and Echo commands since it is logical to think that Print would cost more in resources to operate. This logic is actually true, although the differences in performance are so small that it isn't even worth choosing one construct over the other solely based on performance.
So far the industry standard has been to use Echo, but it should be stressed that either command may be used at will. Echo seems to be the favorite as it is easier to type, not to mention it's a fun word to say! Those who favor the Print command are usually older programmers, who are accustomed to using the command Print from other programming languages that are now considered archaic.
As a last note of worthiness, it should be made clear that if speed is an issue, more emphasis should be put on how the two commands are used. Repeatedly using either command where a programmer could simply concatenate a string or value together will waste system performance- and on a much more noticeable scale that the difference between returning a value or not. Thus, this subject should be addressed if anything in regards to speed.
Closing Comments
End the end, the battle between Echo and print is never ending. The trends do seem to show that Echo is much more popular, but with little reasons. The speed benefit is so small that it's negligible- especially among faster systems that technology has produced where such effects go unnoticed. And because many books and online publications stick true to the Echo command, it's likely we'll only be seeing more of it as time goes on, and less of the fabled Print command that older generations have favored.
About the Author
Learn more on Echo Vs Print and Echo Example.
Comments
No comments posted.
You do not have permission to comment. If you log in, you may be able to comment.
