php code blocks
Posted: Sun Sep 25, 2005 9:13 am
I notice how we have PHP code blocks on this site..how the hell would I begin to go about doing that for my website? I don't even have a clue where to begin :-/ thanks for any tips.
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
<?php
function highlight_php($string)
{
$Line = explode("\n",$string);
for($i=1;$i<=count($Line);$i++)
{
$line .= " ".$i." <br>";
}
ob_start();
highlight_string($string);
$Code=ob_get_contents();
ob_end_clean();
$header='<table border="0" cellpadding="0" cellspacing="0" width="95%" style="border-style: solid; border-width:1px; border-color: white black black white">
<tr>
<td width="100%" colspan="2" style="border-style: solid; border-width:1px; border-color: white; background-color: #99ccff; font-family:Arial; color:white; font-weight:bold;">Php-Code:</td>
</tr>
<tr>
<td width="3%" valign="top" style="background-color: #99ccff; border-style: solid; border-width:1px; border-color: white;"><code>'.$line.'</code></td>
<td width="97%" valign="top" style="background-color: white;"><div style="white-space: nowrap; overflow: auto;"><code>';
$footer=$Code.'</div></code></td>
</tr>
</table>';
return $header.$footer;
}
?>