phpicoder Nov 2, 2021 php

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.

  1. echo
  2. print

Difference between `echo` and `print`

echo:

This statement can pass multiple string separated by ','.

It doesnot return any values.

It is faster compared print.

Example:

<?php
  echo "<h2>Welcome phpicoder</h2>";
  echo "I'm PHP Debelopoer!<br>";
  echo "Hello ", "This ", "string ", "was ", "made ", "with multiple parameters.";
?>
Output:
Welcome phpicoder
I'm PHP Debelopoer!
Hello This string was made with multiple parameters.

print: 

It cannot pass multiple strings.

It always return 1.

It is slower compared echo.

Example:

<?php
  print "<h2>Welcome phpicoder</h2>";
  print "I'm PHP Debelopoer!<br>";
  print "We are learn in PHP!";
?>'
Output:>
Welcome phpicoder
I'm PHP Debelopoer!
We are learn in PHP!

I hope this tutorial help for you.