The PHP builtin function echo(), just like the print() one are used to output text. Basically, both functions work the same, try it:
Step 1) Create a file, save it as PHP, e.g. “test.php”
Step 2) Edit the file by adding the following code:
< ?php
// this is a comment, it will be ignored
echo '1';
echo ('2');
echo '3';
print '4';
/*
another comment (this time, a multiline one)
what I'm doing here is to show you different
ways to output text inside browsers using PHP
*/
?>
Step 3) Save the “test.php” file after you’re done with the editing part.
Step 4) Put “test.php” on your webserver, and access it using your browser at http://serverhostname/test.php – You will see on the page, the following text, based on the example provided at step 2:
—————– browser top ———————
1234
—————– browser bottom —————-
6 Comments