note 44463 added to function.highlight-file

From: Date: Fri, 06 Aug 2004 21:18:49 +0000
Subject: note 44463 added to function.highlight-file
Groups: php.notes 
Request: Send a blank email to php-notes+get-79936@lists.php.net to get a copy of this message
heres mine, it comes out looking pretty good. im sure someone could improve it if they needed more. converts to xhtml and has highlighted numbered lines on the left, the format is pretty solid. youll need to add the css to your <head> ######################## <style type="text/css"> #phpsource div { height: 20px; } #phpsource div b { width:35px; margin-right:10px; text-align:center; background:#F3F9BE; color:#6a7a7a; border-left:solid 1px #CCC; border-right:solid 1px #CCC;} </style> <div id="phpsource"> <code> <?php function xhtml_highlight($file, $return=FALSE) { $html = str_replace('</font>', '</span>', str_replace('<font color="', '<span style="color:', highlight_file($file, TRUE))); $lines = explode("\r", $html); array_unshift($lines, '00'); $i=1; while (false !== ($line = next($lines))) $string .= str_replace('<br />', '<div><b>'.$i++.'</b>', $line."</div>\r\n"); if ($return) return $string; echo $string; } /* just use it like normal, optional return or default print. */ $file = 'highlightme.php'; xhtml_highlight($file); ?> </code> </div> ---- Manual Page -- http://www.php.net/manual/en/function.highlight-file.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+44463 Delete -- http://master.php.net/manage/user-notes.php?action=delete+44463&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+44463&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#79936) next »