Differences

Echo vs. Print in PHP

Written by Anuj kumar

Echo() and Print() are not functions but language constructs in PHP. They are both used to output strings and there are very minor differences between echo and print in PHP.

Echo (PHP) Print (PHP)
Parameters echo can take more than one parameter when used without parentheses. The syntax is echo expression [ expression[ expression] … ]. Note that echo ($arg1 $arg2) is invalid. Print only takes one parameter.
Return value Echo does not return any value Print always returns 1 (integer)
Syntax void echo ( string $arg1 [ string $… ] ) Int print ( string $arg )
What is it? In PHP echo is not a function but a language construct. In PHP print is not a really function but a language construct. However it behaves like a function in that it returns a value.

About the author

Anuj kumar

I'm Anuj kumar a web developer with 4+ year experience .I write blogs in my free time. I love to learn new technologies and share with others. I founded PHPGurukul in September 2015. The main aim of this website to is provide php , jquery , mysql , phpoops and other web development tutorials. I am trying best effort to make PHPGurukul useful for every single moment spend on this website. If you think this website is useful to visit please share with your friend and buddies.