PHP Output

PHP Output

To display the result of a PHP script, there are two basic commands. They are echo and print. Both these commands are used in PHP to display any text. The only difference between these two commands is that print() function is slower than echo() function. Hence, echo has an upper hand and is used more. Let’s understand both these functions with the help of examples.
echo function
Let’s see an example below to display the text, “My first PHP program!”.

<html>
<body>
<?php
echo “My first PHP program!”;
?>
</body>
</html>

The output will be:

My first PHP program!

print function
The print function is used in a manner similar to echo statement.

<html>
<body>
<?php
print (My first PHP program!);
print “My first PHP program!”;
?>
</body>
</html>

The output will be:

My first PHP program!
My first PHP program!

If you have found my website useful, please consider buying me a coffee below 😉