PHP echo and print statements
- In this tutorial you will learn how to use the PHP echo and print statements to display the output in a web browser.
- PHP use then echo and print statement to display the output.
PHP have a two ways to get the output.
- echo
Difference between `echo` and `print`:
echo | |
---|---|
This statement can pass multiple string separated by ','. | It cannot pass multiple strings. |
It doesnot return any values. | It always return 1. |
It is faster compared print. | It is slower compared echo. |
Example of echo:
Edit it yourself
<!DOCTYPE html>
<html>
<body>
<?php
echo "<h2>Welcome phpicoder</h2>";
echo "I'm PHP Debelopoer!<br>";
echo "Hello ", "This ", "string ", "was ", "made ", "with multiple parameters.";
?>
</body>
</html>
Output of PHP echo
Edit it yourselfWelcome phpicoder
I'm PHP Debelopoer!
Hello This string was made with multiple parameters.
Example of print:
Edit it yourself
<!DOCTYPE html>
<html>
<body>
<?php
print "<h2>Welcome webthestuff</h2>";
print "I'm PHP Debelopoer!<br>";
print "We are learn in PHP!";
?>
</body>
</html>
Output of PHP print
Edit it yourselfWelcome webthestuff
I'm PHP Debelopoer!
We are learn in PHP!