Echo and Print in PHP | PHP tutorial

In PHP the output can be seen using two statements : echo and print. Echo statement is the most basic way to display output in PHP.

Within PHP, ‘echo’ is a not a function, rather it is a language construct, so there is no need to use parentheses() with it.

PHP can be used to output both strings or variables. Following are some of the usage of echo statement in PHP.

Display Text

In order to display any text, simply write the echo followed by the statement,message or text you want to display, within the quotes.


Printing text in PHP

Display Variables

The below example displays how you can display variables using echo statement in PHP.


hello world


In the above statement the second echo statement is used to print <br> tag. As this tag is used to provide a line break, this statement will print a line break.

The last echo statement uses combination of strings and variables. Multiple strings are connected in PHP using (.) dot operator. This is known as concatenation in PHP.

Each user defined string must be passed within quotes in PHP.

Difference between Echo and Print in PHP

In PHP, Echo and Print bot statements are used to output data but with some differences

Echo has no return value while print has return value of 1

Echo can have multiple parameters while print has only one parameter

Echo statement is faster than print statement.

Echo Statement

echo ($arg1,$arg2,$arg3....)

Print Statement

print ($arg)

Tags – Echo vs Print statement, Different between echo and print statements in php. How to print a message or variable in php.

Author: Deepak Kumar

This is Deepak Kumar, founder of True Infosystems and of-course the chief content creator at Started my carrier as a Freelancer and now a top-rated Freelancer at Upwork, delivered over 200 successful projects with highly positive user ratings and counting.