当前位置: 首页 > 图文教程 > 网络编程 > PHP > 高亮度显示php源代码

PHP
编写自己的php扩展函数
用Socket发送电子邮件
Get或Post提交值的非法数据处理
一个可查询所有表的“通用”查询分页类
拼音码表的生成
一个odbc连mssql分页的类
用PHP动态创建Flash动画
如何使用PHP获取网络上文件
PHP中路径问题的解决方案
论坛头像随机变换代码
十天学会php(2)
十天学会php(1)
十天学会php(3)
PHP自动生成月历代码
关于PHP中的Class的几点个人看法
Win9x/ME下Apache+PHP安装配置
基于PHP+MySQL的聊天室设计
PHPlet在Windows下的安装
Search Engine Friendly的URL设计
如何给phpadmin一个保护

PHP 中的 高亮度显示php源代码


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 49 ::
收藏到网摘: n/a


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