Arrow

PHP echo and print Statements

AuthorHariom Prajapati

Pubish Date24 Jul 2022

categoryPHP

  • Echo and print both are almost same, which is used to get output.
  • The echo statement can be used with parentheses: echo() or without parentheses: echo.
  • The print statement can be used with parentheses: print() or without parentheses: print.

 

There are two different methods to get output in PHP

  • echo or echo( )
  • print or print( )

 

Example

<!DOCTYPE html>
<head>
  <title>Document</title>
</head>

<body> 

<?php
print"This is print statement.<br>";
echo"This is echo statement.<br>";
print("This is print statement. <br>");
echo("This is echo statement.<br>");
?>

</body>

</html>

 

Output

php echo and print statement