About us Privacy Disclaimer Contact us
FAQ Help Advertising Feedback
Home Sitemap Search Donate us

  Home > Computer & I'net > Print/Echo...

   Browse by title articles:
   What is hot:

Escape Characters

Operators

Print/Echo

Variables

Numbers - Formatting

Numbers - Math

Merging Arrays
if/elseif/else
Know linux
Clickbank Security Using PHP
Prev articles12345 6 789101112Next articles



Print/Echo


Computer & I'net articlesPrint/Echo

by David Stanley    



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!



-----------------
Article by David Stanley. Visit his site http://www.htmlite.com. Reprinted with permission.





Savings Estimator




  Disclaimer | Privacy | Terms of useCopyright © 2004 Nice2know.com