ECHO:
echo and print are more or less the same.
echo() and print() are language constructs in PHP, both are used to output strings. The speed of both statements is almost the same.
echo() can take multiple expressions
Example:
2 3 4 5 6 7 8 9 |
<?php echo "<h2>PHP is Fun!</h2>"; echo "Hello world!<br>"; echo "I'm about to learn PHP!<br>"; echo "This ", "string ", "was ", "made ", "with multiple parameters."; ?> |
Print Statement:
The print statement can be used with or without parentheses: print or print().
Print return true or false based on success or failure whereas echo doesn’t return true or false.
print cannot take multiple expressions.
Example:
2 3 4 5 6 7 8 |
<?php print "<h2>PHP is Fun!</h2>"; print "Hello world!<br>"; print "I'm about to learn PHP!"; ?> |
Pradeep Maurya is the Professional Web Developer & Designer and the Founder of “Tutorials website”. He lives in Delhi and loves to be a self-dependent person. As an owner, he is trying his best to improve this platform day by day. His passion, dedication and quick decision making ability to stand apart from others. He’s an avid blogger and writes on the publications like Dzone, e27.co