正 文

PHP实现高亮度代码


www.7dspace.com  更新日期:2005-8-17 3:48:17  七度空间


  <?
  function HeighPHPcode($Heightstring){
  do{
  $z=0;
  if(preg_match('/<phpcode>(.*)</phpcode>/sU',$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("/<phpcode>(.*)</phpcode>/sU","$code",$Heightstring,1);
  }
  }while($z);
  return $Heightstring;
  }
  ################################################
  #$PHPcode就是要被加亮的代码
  $PHPcode="<phpcode>echo \"fdsfdsfds\";</phpcode>";
  ################################################
  echo HeighPHPcode("$PHPcode");
  ?>

上一篇:BS结构中使用PHP访问ORACLE LOB
下一篇:PHP新手上路基础教程目录
作者:  来源:七度空间 ( 责任编辑:7dspace )
收藏此页】【打印】【关闭
站 内 搜 索
 

热 点 导 读
特 别 推 荐