You are here: Re: PHP to echo a line in html source... « PHP Programming Language « IT news, forums, messages
Re: PHP to echo a line in html source...

Posted by Hilarion on 08/23/05 23:45

> [snip]
> <?php
> echo '<table>';
> echo '<tr>';
> echo '<td> blah blah </td>';
> echo '</tr>';
> echo '</table>';
> ?>
>
> [snip]
>
> Is there anyway I can get each html tag on a seperate line in the html
> source so it is nice and neat (easy readable)?

Many ways.
First one (using double quotes and escape sequence \n):

<?php
echo "<table>\n";
echo "<tr>\n";
echo "<td> blah blah </td>\n";
echo "</tr>\n";
echo "</table>\n";
?>

or:

<?php
echo "<table>\n<tr>\n<td> blah blah </td>\n</tr>\n</table>\n";
?>

or:

<?php
echo '<table>'."\n";
echo '<tr>'."\n";
echo '<td> blah blah </td>'."\n";
echo '</tr>'."\n";
echo '</table>'."\n";
?>

or escaping to HTML:

<?php
// some PHP code
?>
<table>
<tr>
<td> blah blah </td>
</tr>
</table>
<?php
// other PHP code
?>

or using multiline strings (and double quotes):

<?php
echo "<table>
<tr>
<td> blah blah </td>
</tr>
</table>
";
?>

or (probably) many more.


Hilarion

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация