shadowline
Operators << Print/Echo >> Variables
Ready to start doing some coding yet?

print and echo are commands used to output information to the visitors screen (on the web page). Both do the same job, so it usually comes down to a matter of personal preference on which one you like to use.

<?php
print "Hello World! <br />";
echo "Hello World!";
?>

The output :
Hello World!
Hello World!

The above example shows both outputs are the same. It also shows that regular HTML tags may be placed within the value areas as well as regular text.

There is a slight difference between print and echo which would depend on how you want to use the outcome. Using the print method can return a true/false value. This may be helpful during a script execution of somesort. Echo does not return a value, but has been considered as a faster executed command. All this can get into a rather complicated discussion, so for now, you can just use whichever one you prefer.

Some resources will state that the quoted areas should be within rounded brackets. This is a valid way of coding, but not required.

<?php
print ("Hello World!");
?>

If you need to use quotes within your value area and have them show up on the web page, you will have to "escape" them. This is so the coding does not get confused on which quotes are the real ones and which ones are for display.
<?php
print "Hello from \"another\" World!";
?>

Will result as :
Hello from "another" World!
Operators << Print/Echo >> Variables
shadow

Advertise in the banner along the top, Click here!

Valid XHTML 1.0 Transitional Valid CSS! Text Link Ads
shadow
shadow