1. Home
  2. Computing & Technology
  3. PHP / MySQL

Formatting Your PHP
Making Your PHP Pretty

By Angela Bradley, About.com

So you've gone though some of the tutorials, and you can make some nifty things in PHP. But the problem is, they all look like plain text. How do you jazz them up?

Formatting with PHP actually isn't done with PHP, it's done with HTML. You can do this in two ways. You can add the HTML inside of the PHP... or you can add the PHP inside of the HTML. Either way, make sure your file is saved as a .php or another file type that is allowed to execute PHP on your server.

Let's do something simple.... let's make our text red!

HTML inside PHP

<?php
echo "<font color=#ff0000>Hello World!</font>";
?>
Notice how we include the HTML code right inside of the echo.

PHP inside HTML

<font color=#ff0000>
<?php echo "Hello World!"; ?>
</font>
In the second example we simply insert a line of PHP inside our HTML. Although here it is only a line to make the text red, this could be inside a fully formatted HTML page, to get any look you want.
More PHP / MySQL Quick Tips
Explore PHP / MySQL
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. PHP / MySQL
  4. Learn PHP
  5. Format Your PHP - Make PHP Pages Pretty

©2009 About.com, a part of The New York Times Company.

All rights reserved.