PHP 高亮类
时间:2006-07-07 来源:elfen
[Copy to clipboard] [ - ] CODE:
function phphighlite($code) {
//PHP 4 only
if (floor(phpversion())", ">", $code);
$code = str_replace("
$code = str_replace("&", "&", $code);
$code = str_replace('$', '\$', $code);
$code = str_replace('\n', '\\\\n', $code);
$code = str_replace('\r', '\\\\r', $code);
$code = str_replace('\t', '\\\\t', $code);
$code = stripslashes($code);
if (!strpos($code,"";
$addedtags=1;
}
// if (!strpos($code,"[code]") and substr($code,0,6)!="[code]") {
// $code="[code]\n".trim($code)."\n[\/code]";
// $addedtags=1;
// }
ob_start();
$oldlevel=error_reporting(0);
highlight_string($code);
error_reporting($oldlevel);
$buffer = ob_get_contents();
ob_end_clean();
if ($addedtags) {
$openingpos = strpos($buffer,'PHP代码:$buffer";
return "$buffer";
}
//PHP 4 only
if (floor(phpversion())", ">", $code);
$code = str_replace("
$code = str_replace("&", "&", $code);
$code = str_replace('$', '\$', $code);
$code = str_replace('\n', '\\\\n', $code);
$code = str_replace('\r', '\\\\r', $code);
$code = str_replace('\t', '\\\\t', $code);
$code = stripslashes($code);
if (!strpos($code,"";
$addedtags=1;
}
// if (!strpos($code,"[code]") and substr($code,0,6)!="[code]") {
// $code="[code]\n".trim($code)."\n[\/code]";
// $addedtags=1;
// }
ob_start();
$oldlevel=error_reporting(0);
highlight_string($code);
error_reporting($oldlevel);
$buffer = ob_get_contents();
ob_end_clean();
if ($addedtags) {
$openingpos = strpos($buffer,'PHP代码:$buffer";
return "$buffer";
}
相关阅读 更多 +