PHP - Echo & Print

In PHP the two basic constructs to get output are echo and print.we covered in this topic both type echo and print the following with syntax and it's example.

Echo

echo() is not a function, it is a language construct therefore you can use it with and without parentheses for example echo and echo() the following synax and example of echo.

Example



<?php
	echo "This is Without Parentheses";
	echo ("This is With Parentheses");
?>			
							

Print

print it is a language construct therefore you can use it with and without parentheses for example print and print() the following synax and example of print.

Example



<?php
	print "This is Without Parentheses";
	print ("This is With Parentheses");
?>							
						
							

Difference Between Echo and Print


Sr.No

Echo

Print

1

Echo is a statement i.e used to display the output. it can be used with parentheses echo or without parentheses echo.

Print is a statement i.e used to display the output.it can be used with parentheses print( ) or without parentheses print.

2

Echo can pass multiple string separated as ( , )

Using print can doesn’t pass multiple argument

3

Echo doesn’t return any value

Print always return 1

4

Echo is faster then print

Print slower than echo

are you understand above echo and print,read the next topic name datatype in php click on next button and read now.

Share Share on Facebook Share on Twitter Share on Google+ Share on LinkedIn Pin on Pinterest Share on Stumbleupon Share on Tumblr Share on Reddit Share on Diggit