PHP Echo Statement

echo is used to output data to the screen. PHP echo statement can be used to print the string, multi-line strings, escaping characters, variable, array, etc.

The echo statement can be used with or without parentheses: echo or echo().

Example



<?php
//The following example shows how to output text with the echo command (notice that the text can contain HTML markup):
echo "<h2>PHP is Fun!</h2>";
echo "Hello world!<br>";
echo "I'm about to learn PHP!<br>";
echo "This ", "string ", "was ", "made ", "with multiple parameters.";

//The following example shows how to output text and variables with the echo statement:
$txt1 = "Learn PHP";
$txt2 = "TheNewTutorial.com";
$x = 5;
$y = 4;

echo "<h2>" . $txt1 . "</h2>";
echo "Study PHP at " . $txt2 . "<br>";
echo $x + $y;

//Displaying Strings as multiple arguments:
echo "<br><br>Multiple ","argument ","string!";

?> 
PHP Echo Statement example – Output