| Home > Computer & I'net > Print/Echo... |
|
|
|||||||||||||||
|
|
|||||||||||||||
|
||||||||||||||||
Print/Echo | |
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. | |
| Articles |
•Auto & Trucks•Business•Computer & I'net·General·Apache·CSS·Database·Hardware·HTML·Javascript&DHTML·Linux·MySQL·Operating System·Perl / CGIPHP·Programming·Publishing·Search Engines·Software Problems·SSI·Tips & Tricks·Utilities·Web Design•Family•Food & Drink•Gardening•Health•Other•Pets•Psychology•Spiritual•Travel•Women |
| Calculators |
|