header
 
     
 
pixel
pixel pixel

Making your HTML readable when using PHP

If you're using PHP to output HTML (common with dynamic websites), your HTML can become quite unreadable if all your code is on a single line. When echoing a line of output, be sure to slap a line break \r\n at the end of the line so your HTML is broken up into separate lines. Eg -
echo "<img src='pic.gif'><br>\r\n";

Unhelpful Helpful Rating 3.1 (score out of 5, no. of ratings: 18)
Comments
Comment by David Dorward on 2004-04-22
Or leave PHP when you don't really need to be using it:
?>
<img src="pic.gif" alt="The alt attribute has been required since 1996"><br>
<?php
Or use heredoc syntax (which lets you use variables inside it):
print <<<EOF
<img src="pic.gif" alt="The alt attribute has been required since 1996"><br>

EOF;

Comment by Ruben Ayala on 2007-07-27
Thanks for your help...

Post a Comment
Name
Email
(optional)
Comment
RatingUnhelpful Helpful
Security Image* (this is just to prevent spam submissions)
Security Image