echo in PHP

echo is using for output one or more strings in PHP.

echo is basically a language construct and not a function. So we can use without parentheses with it.

We can run shell commands also using shell_exec in PHP echo syntax.But its only used in advanced PHP programming and we will discuss more about this in our later posts.

We can use the HTML formatting tags with PHP echo statement

See the following sample program with echo in PHP programs

<?php
echo "Good Morning";
?>

Its out put will be :
Good morning

<?php
echo "<b>Good Morning</b>";
?>

Its out put will be :
Good morning

<?php
$variable1="PHP";
$variable2="MySQL";
echo $variable1."&".$variable2;
?>

Its out put will be :
PHP&MySQL

<?php
$variable1="PHP";
$variable2="MySQL";
echo $variable1."<br />".$variable2;
?>

Its out put will be :
PHP
MySQL

Share

2 thoughts on “echo in PHP”

  1. Some unofficial reports saying that “echo” is faster than “print” statement in PHP

Comments are closed.

Share
Share