PHP Echo And Print

tutorial and example
tutorial and example

In PHP, echo and print is used to get output data to the screen but there is some difference, between echo and print.

  • PHP echo

PHP echo is used to display the output data.It can be used with parentheses or without parentheses.

We can pass multiple stringsseparated by(,) comma operator.

It does not return any value.

Example 1

Output

RasmusLerdorfRasmusLerdorf

Example 2 (pass multiple argument)

Output

RasmusLerdorf

PHP print

PHP print is also used to display the output. We cannot pass multiple arguments in print.

It does return value 1.

Example1

Output

RasmusLerdorf

Example2

Output

Rasmus Lerdor1

Followingare the difference between Echo andprint.

                        PHP Echo PHP Print
Echo has no return value. Print has a return value 1.
We can use multiple parameters in echo. We can only use one argument.
Echo is faster than print. It is slow.