by Zachary Schuessler

The Internet for webmasters just wouldn’t be the same without the language of PHP. PHP has given webmasters a long-lasting relationship with their websites, to manipulate it to best offer customers and Internet users what they need. But before becoming the master PHP expert, learning smaller details is important. And interestingly enough, many PHP developers don’t know the difference between Echo and Print.

Two commands are used to output text to the screen: Print and Echo. But since both do the same thing, why would there be two different commands? The answer, interestingly enough, eludes even some PHP experts.

The two language constructs Print and Echo differ because Echo does not return a value- although Print does. This is an odd thing to have, however, since a command used to output data to the screen will almost never need to return a value. In fact, even those who have been in the programming industry for years have probably never seen a good use of Print where Echo couldn’t follow.

While performance may be a big issue for PHP developers and their clients, the debate between Print and Echo is actually fairly meaningless. It is true that Print will take more system resources to use, but it is such a minimalistic amount that developers are recommended to choose the construct of their choice, regardless of speed issues.

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.

In Conclusion

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: