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.
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; |
Output of the above example will be :
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]; |