高亮度顯示php源代碼
更新時(shí)間:2006年10月09日 00:00:00 作者:
高亮度顯示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");
?>
相關(guān)文章
php入門(mén)學(xué)習(xí)知識(shí)點(diǎn)四 PHP正則表達(dá)式基本應(yīng)用
php入門(mén)學(xué)習(xí)知識(shí)點(diǎn)四 PHP正則表達(dá)式基本應(yīng)用,正則也是php中常用的,大家一定要掌握下。不會(huì)的可以到腳本之家首頁(yè)查看正則基礎(chǔ)教材。2011-07-07
分享下PHP register_globals 值為on與off的理解
從 PHP4.2.0版本開(kāi)始,php.ini中的設(shè)置選項(xiàng) register_globals 默認(rèn)值變成了 off。所以,最好從現(xiàn)在就開(kāi)始用Off的風(fēng)格開(kāi)始編程2013-09-09
php面向?qū)ο笕ヂ?(四)構(gòu)造方法與析構(gòu)方法
大多數(shù)類都有一種稱為構(gòu)造函數(shù)的特殊方法。當(dāng)創(chuàng)建一個(gè)對(duì)象時(shí),它將自動(dòng)調(diào)用構(gòu)造函數(shù),也就是使用new 這個(gè)關(guān)鍵字來(lái)實(shí)例化對(duì)象的時(shí)候自動(dòng)調(diào)用構(gòu)造方法。2009-09-09
優(yōu)化NFR之一 --MSSQL Hello Buffer Overflow
優(yōu)化NFR之一 --MSSQL Hello Buffer Overflow...2006-10-10

