Chinaunix首页 | 论坛 | 博客
  • 博客访问: 18076388
  • 博文数量: 7460
  • 博客积分: 10434
  • 博客等级: 上将
  • 技术积分: 78178
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-02 22:54
文章分类

全部博文(7460)

文章存档

2011年(1)

2009年(669)

2008年(6790)

分类:

2008-05-16 17:17:50

高亮度显示php源代码
function Heighcode($Heightstring){
do{
   $z=0;
   if(preg_match('/(.*?)/s',$Heightstring,$reg)) {
     $z=1;
     $code=';
     ob_start();
     highlight_string($reg[1]);
     $code = ob_get_contents();
     ob_end_clean();
     $reg[1] = addslashes($reg[1]);
     $Heightstring=preg_replace("/(.*?)/s","$code",$Heightstring,1);
    }
}while($z);
return $Heightstring;
}
##########################################################################################
#$PHPcode就是要被加亮的代码
$PHPcode= <<
function HeighPHPcode($Heightstring){
do{
   $z=0;
   if(preg_match('/(.*?)/s',$Heightstring,$reg)) {
     $z=1;
     $code=';
     ob_start();
     highlight_string($reg[1]);
     $code = ob_get_contents();
     ob_end_clean();
     $reg[1] = addslashes($reg[1]);
     $Heightstring=preg_replace("/(.*?)/s","$code",$Heightstring,1);
    }
}while($z);
return $Heightstring;
}

END;
##########################################################################################
echo   HeighPHPcode("$PHPcode");
?>

阅读(536) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~