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

PHP
实现树状结构的两种方法
PHP4(windows版本)中的COM函数
多文件上传的例子
PHP中的超全局变量
PHP树的代码,可以嵌套任意层
强烈推荐:php.ini中文版(1)
强烈推荐:php.ini中文版(2)
国内php原创论坛
PHP&MYSQL服务器配置说明
Apache设置虚拟WEB
提升PHP执行速度全攻略
Mysql的常用命令
用Apache反向代理设置对外的WWW和文件服务器
php.ini中文版
ASP知识讲座四
一个用于MySQL的PHP XML类
phpmyadmin操作流程
PHP4中实现动态代理
把PHP安装为Apache DSO
正则表达式语法

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 87 ::
收藏到网摘: 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");
?>