<?php /* Part of http://netcat.sourceforge.net/ */
// Use class names instead of colors ini_set('highlight.comment', 'comment'); ini_set('highlight.default', 'default'); ini_set('highlight.keyword', 'keyword'); ini_set('highlight.string', 'string'); ini_set('highlight.html', 'html');
// Highlight PHP code -- from http://www.php.net/include/layout.inc function highlight_php($code, $return = FALSE) { // Using OB, as highlight_string() only supports // returning the result from 4.2.0 ob_start(); highlight_string($code); $highlighted = ob_get_contents(); ob_end_clean(); // Fix output to use CSS classes and wrap well $highlighted = '<div class="phpcode">' . str_replace( array( ' ', '<br>', '<font color="', '</font>', "\n ", ' ' ), array( ' ', "<br>\n", '<span class="', '</span>', "\n ", ' ' ), $highlighted ) . '</div>';
if ($return) { return $highlighted; } else { echo $highlighted; } }
|