שלום,
אז ככה יש לי את הפונקצייה הבאה:
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:</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;
}
שבעעצם אמור לעשות מעין תגיות CODE כמו פה. אם אני רוצה ליצור תגיות אני עושה ככה:
PHP קוד:
$test="test \n test \n";
$active=highlight_php($test);
echo $active;
עכשיו השאלה שלי איך אני יכול לעשות במקום לקרוא לפונקצייה ככה:
PHP קוד:
$test="test \n test \n";
$active=highlight_php($test);
echo $active;
פשוט לעשות
תודה.
(אם לא הבנתם משהו אתה מוזמנים לשאול.)
ניתן לראות דוגמא פה:
http://elad.fire-serv.net/1.php