Advertising PICS Tools // The best online resource for Webmasters!

Your Ad Here

 

PHP Tutorials > Echo Command

The echo command provides you with a way to output your string variables. It is a vital part of the PHP language mainly based on it use for outputing error messages as well as outputing success messages. By the end of this tutorial you should be able to integrate this into a project.

First off, you can use a string variable or use quotes (single and double) to display your echo. Below we have used both:


<?php
$string = 'test 1';
echo $string;
echo 'test 2';

?>
 
 

Outputs the following: test 1 test 2

Don't Create A Problem, Keep Reading!

One major issue with the echo command is people typically output HTML with it. Adding HTML is actualy a great use of this tool but most people run into problems with certain codes.

When using codes like for instance <font face="tahoma"> in echo ""; they run into an error because they are using double quotes. The best way to fix this would be using a "\" or simple using the opposite (i.e: single and double).

If you are writing something in email for instance and have a long amount of text that needs paragraph spacing you can use a period. Look below:


<?php
$string = "test 1" . "\r\n\n" . "test 2" . "\r\n" . "test3";
echo $string;

?>
 
 

This will ensure you receive your spaces without creating a problem with the quotes.

If you have more questions on this please ask in the discussion board!

Go Back To PHP Tutorials

 

 

Does Every Day Feel Like Monday? Visit 4Jobs.com

Advertising | Services | Support
Copyright © 2007 All Rights Reserved.

Welcome
Username:
Password:

Register | Forgot Password
Spankin New
Blog
11.04.07 Are You Ready -- Affiliate Programs and Mobile PT?
09.27.07 One of the Biggest Scams Ever, Watch Out
09.26.07 Johnny Appleseed Day -- Delicious Day
09.25.07 What Do Wendie Ann Schweikert, Allena Ward, Nan Goldin, and Halo 3 Have In Common? Google.
09.21.07 Dover, De - Small Town, Big Crime
More...

Server Status

Check to see if your website's server is running the way you want it
Short Url
Have a lengthy web address? With our new program you can shorten it!


Services
Tutorials
Have a problem? We can help, Check out our tutorials and support forums!