PHP echo function

PHP echo function: Echo function is used to print the strings in php.

PHP echo function Syntax

echo strings

strings : Input Strings.
Return : Will print string.

Note 1 : Parenthesis are not required as “echo” is not function actually. It is construct. So you need not to use parenthesis with the echo.

Note 2 : Echo is faster than the print so we prefer to use echo instead of print.

PHP echo Function Example 1

$string = "Hi It's me Kelly!";
echo $string;

Try it »

As you see in the above example we have not used the parenthesis like this :echo($string) which is incorrect.

The below example shows the concatenation of the two strings.

PHP echo Function Example 2

$string1 = "Hi I am John !";

$string2 = "A Young Developer.";

echo $string1.' '.$string2;

Try it »

Output of the above example will be :

PHP echo Function Example

PHP echo() Function Example

Let us print an array using echo.

PHP echo Function Example 3

$array = array("0"=>"Tani","1"=>"The PHP Developer");
echo $array[0].' '.$array[1];

Try it »


Add Comment

📖 Read More