20 Apr 2013

What is echo and print

print and echo are both used to output data to browser software or other technologies that intake external data. As you come to view different PHP scripts in your travels online you may notice some authors use echo and some use print. Let us discuss the difference.

echo() = is a language construct, so you are not required to use parentheses with it. If you ever need to pass more than one parameter to echo(), the parameters must not be enclosed within parentheses.

print() = behaves as a Function, but is not actually a function. print is sometimes mistaken as a function by many programmers since it sets a return value, but it is also a language construct like echo. It simply outputs a string of data. And you are not required to use parentheses with it.

Example code













Output will be the same.