PHP – echo Statement

“echo” and “print” statements in PHP

Both “echo” and “print” statements are used to display the output of any php variable and script. So in this chapter we will understand how we will use the “echo” and “print” statements in the php program and we will also see the differences in both “echo” and “print” statements.

Main differences between “echo” and “print” statements in PHP

As both “echo” and “print” are not actually a PHP functions instead these are the PHP language construct. So we are not required to use the parathenses while using these functions.

Here are the main differences in “echo” and “print”

1. echo print the output faster than print.

2. echo doesn’t return any value instead print returns a value of 1. So print can also be used in expressions.

3. echo can pass multiple parameters if needed instead print can pass only one parameter.

I hope the above three points clears the differences in both.

Example “echo” statement in PHP

Example “print” statement in PHP



Leave a Reply

Your email address will not be published.