The Difference Between PHP Echo and Print

In PHP two of the commands that are used to output text on the screen are called Print and Echo. Since both of these commands do the same thing, few people know the actual difference between the two. The principle difference is that the print command returns a value while the echo command does not return anything. Therefore it maybe useful for developers to use the print command during a script execution of some sort where they require the script to return a value. On the other hand some experts have said that the echo command is executed faster than the print command.

So which one should you use? The unwritten standard is to use Echo and more developers use echo as opposed to print. Although there is no real benefit in using echo over print, most developers have chosen it unless they require a return value. It is also wise to keep in mind that Print is not a function, contrary to popular belief. Print is and echo are both language constructs.

Which is better? This is a matter of personal preference. Since the principle difference is almost never used and speed is a negligible factor, you can choose which ever construct you feel comfortable using in your PHP code.