PHP Echo Statement

In php the echo statement can be used to output data to the screen. In general, the echo statement can display anything that can be displayed to the browser, such as string, numbers, variables values etc. Example :
<?php
  echo "Hello world";
  echo "<br/><b>This is the test string.</b>";
  echo "<br/><i>Another Test line</i>";
?>
Output :

Hello world
This is the test string.
Another Test line

As we can see at the above example the echo statement print display text and some text also contain HTML markup. And also note that the echo statement is a language construct not a function, therefore we can use it with or without the parentheses. And unlike the print() echo does not return any value. Now lets see some examples :

Printing Variables with echo :
<?php
  $num = 1000;
  $float = 25.80;
  $str = "Hello world";

  echo "The \$num value is : " . $num . "<br/>";
  echo "The \$float value is : " . $float . "<br/>";
  echo "The \$str value is : " . $str . "<br/>";
?>
Output :

The $num value is : 1000
The $float value is : 25.8
The $str value is : Hello world

At the above example the back slash ( \ ) is used to escape the $ character. lets see another example of escaping characters.
<?php
  echo "This is the \"Important\" character of the string.";
?>
Output :

This is the "Important" character of the string.

Printing Multiple Lines :
<?php
  echo "This is the \"Important\" \
    character of the string
    which prints by using 
    The multiple lines.";
?>
Output :

This is the "Important" \ character of the string which prints by using The multiple lines.

Next Topic :