Home / Web / Difference between echo and print in PHP

Difference between echo and print in PHP

In PHP echo and print both are the PHP Statement. Echo and Print are used to display the output in PHP.


  • It is a statement i.e which used to display the output. Ii can be used with parentheses echo or without parentheses echo.
  • It can pass multiple string separated as ( , )
  • IT doesn’t return any value
  • echo is faster than print

For example:

$name= “Chetan ”;
$work=”Software Developer”;
echo $name , $work , $age, “ Years Old”;

Chetan Software Developer26 Years Old

In the above example, $name , $work and $age are three variable with value=(“Chetan” , “Software Developer” and 26) respectively.
Now we want to print all three variable values together. All variables names are define inside the echo statement separated by comma or dot (, or.)
And we will get the above output.


  • Print is also a statement and used to display the output. Print can be used with parentheses print ( ) or without parentheses print.
  • Using print can doesn’t pass multiple argument
  • print always return 1
  • it is slower than echo

For example:

$name= “Chetan”;
Print $name;
Print ($name);



In the above example, Declare a variable ($name) value=”Chetan”. Now we want to print the name. we simply define $name inside print statement with or without parentheses.

it will show the output: “Chetan”

Speed of both in PHP
The speed of both  statements in PHP is nearly the same. Using one over the other is not likely to yield any performance improvement in your application. Theoretically, echo is more efficient because it does not return any value.

Function vs Language Construct
Unlike most PHP string functions, both aren’t functions but language constructs. Therefore it is not required to use parentheses when using both.

About Helpservices

About This site (allhelpservices.com) is dedicated to helping other bloggers learn the skills of blogging, wordpress, education, technology, social media sharing , SEO, Electronics, Earn Money From Blogging, Web hosting and web share their own experiences and promote the blogging medium. We started Allhelpservices in August 2015 mainly because we wanted to keep a record of what we wear learning from development and because we wanted to connect with other learners.

Check Also

style sheet

What are ways of inserting a style sheet?

Cascading Style Sheets (CSS) describe how documents are presented on screens, in print, or perhaps ...

Leave a Reply