Main Menus
Make cash!
| InfinityWebCr.. Articles: 15 | |
| ReeseLanter Articles: 7 | |
| PattiRob Articles: 5 | |
| JacquesCoquerel Articles: 14 | |
| Audrey18 Articles: 8 | |
This article is licensed under a Creative Commons Attribution-No Derivative Works 3.0 Unported License, which means you may freely reprint it, in its entiretly, provided you include the author's resource box along with LIVE links (without "nofollow" tags).
View PDF | Print View | Html Version
by: ZacharySchuessler
Total views: 2
Word Count: 427
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.
As it turns out, Echo is actually a language construct that doesn't return a value, in which Print does. This simple fact means that Print can be used in some instances where Echo can't, although developers will probably never run into such a situation. In fact, many PHP developers stick with Echo their entire career and will never see a problem.
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.
When a PHP developer looks around at examples and scripts from others in the community, they will see that Echo is used much more often. This isn't because of speed, as previously discussed, but because many think it easier to type and the keyword command is more appealing in design. The success of Echo has been compounded after many publishers make books and online resources that sport the term.
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
PHP development just wouldn't be the same without fun debates such as the one just mentioned. But in reality, it really doesn't matter which route is taken- so long as either language construct is used in a performance-based manner. Although Print may still have somewhat of a following today, as books and publishers start using Echo more often, it's likely we'll see a death to the Print command soon enough.
Learn more on Echo Command and Echo PHP.