PHP ShowCode
Wenn man den Inhalt eines Files oder z.B. den Inhalt eines DB-Memofeldes mit Syntax und Zeilennummern ausgeben will, kann man die Funktion ShowCode verwenden:
<?
function showCode($code) {
$code = highlight_string($code, true);
$code = explode("<br />", $code);
$i = "1";
foreach ($code as $line => $syntax) {
echo "<font color='black'>".$i."</font> ".$syntax."<br>";
$i++;
}
}
?>
function showCode($code) {
$code = highlight_string($code, true);
$code = explode("<br />", $code);
$i = "1";
foreach ($code as $line => $syntax) {
echo "<font color='black'>".$i."</font> ".$syntax."<br>";
$i++;
}
}
?>
Die Funktion kann folgendermassen gebraucht werden:
<?
// Ausgeben einer Datei
showCode(openfile($path."$file","r"));
// Ausgeben einer Variablen
showCode($inhalt);
?>
// Ausgeben einer Datei
showCode(openfile($path."$file","r"));
// Ausgeben einer Variablen
showCode($inhalt);
?>
Popularity: 1% [?]