高亮度顯示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和Mysqlweb應(yīng)用開發(fā)核心技術(shù) 第1部分 Php基礎(chǔ)-3 代碼組織和重用2
創(chuàng)建可以調(diào)用的函數(shù)以便重用代碼把參數(shù)傳遞給函數(shù)并且從函數(shù)返回值和腳本的不同部分中的變量和數(shù)據(jù)進(jìn)行交互2011-07-07PHP編實(shí)現(xiàn)程動(dòng)態(tài)圖像的創(chuàng)建
PHP編實(shí)現(xiàn)程動(dòng)態(tài)圖像的創(chuàng)建...2006-10-10windows8.1下Apache+Php+MySQL配置步驟
這篇文章主要介紹了windows8.1下Apache+Php+MySQL配置步驟,需要的朋友可以參考下2015-10-10PHP個(gè)人網(wǎng)站架設(shè)連環(huán)講(二)
PHP個(gè)人網(wǎng)站架設(shè)連環(huán)講(二)...2006-10-10php imagecreatetruecolor 創(chuàng)建高清和透明圖片代碼小結(jié)
php imagecreatetruecolor 生成圖片示例代碼,需要的朋友可以參考下。2010-05-05