PHP: How to output (echo/print) content in PHP
Table of contents
There are several ways to output data/content. I might have forgotten about one of them
1) A php file with any content apart from
<?php . Without the PHP opening tag, everything else will be echoed out.
echo 'some text'; - a simple echo
print ('some text'); - similar to echo
<?='some text':?> or
5) and via functions such as
There isn't much difference. The only two differences are that
echo does not return any value, and can take multiple arguments (
print() returns a value of 1 and can only take one parameter. Years ago echo() used to be a bit faster, now it would be so insignificant that it is not worth even thinking about which is faster..