note 19326 added to function.highlight-string
| From: | eric at evilwalrus dot com | Date: | Sat, 23 Feb 2002 15:58:48 +0000 |
| Subject: | note 19326 added to function.highlight-string | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-26966@lists.php.net to get a copy of this message | ||
When your highlighting code using highlight_string() it tends to add a lot of
(non-breaking spaces) to the code. This can tend to mess up tables that don't have a set width.
A workaround for now is to remove all of those spaces.
<?
function showsource ($code) {
ob_start();
highlight_string($code);
$colorsource = ob_get_contents();
ob_end_clean();
$colorsource = str_replace (" ", " ", $colorsource);
return $colorsource;
}
$plain_code = "<? php_info(); ?>";
echo showsource($plain_code);
?>
I don't think this will totally solve the problem, but it does help.
--
http://www.php.net/manual/en/function.highlight-string.php
http://master.php.net/manage/user-notes.php?action=edit+19326
http://master.php.net/manage/user-notes.php?action=delete+19326
http://master.php.net/manage/user-notes.php?action=reject+19326