archives
Generating nice HTML with PHP... forget the PHP.
Submitted by phrax on Wed, 2004-10-27 15:12. Bad ArchitectureJumping in and out of HTML in PHP is a fundamental part of the language but what if you didn't know that? What if you wanted PHP to generate some nicely formatted HTML? Props to Thiemo Mättig for sending in this WTF.
This is probably the most 'clever' way of adding in tabs and new lines to format HTML.
<?php
$n = chr(13);
$t = chr(9);
$nt = $n.$t;
$ntt = $n.$t.$t;
$nttt = $n.$t.$t.$t;
$ntttt = $n.$t.$t.$t.$t;
$nttttt = $n.$t.$t.$t.$t.$t;
?>
and a little furthur...
<?php
$html .= $nttt.'<table>';
$html .= $ntttt.'<tr>';
$html .= $nttttt.'<th>...</th>';
$html .= $nttttt.'<th>...</th>';
$html .= $ntttt.'</tr>';
$html .= $ntttt.'<tr>';
$html .= $nttttt.'<td>...</td>';
$html .= $nttttt.'<td>...</td>';
$html .= $ntttt.'</tr>';
$html .= $nttt.'</table>';
?>