<?
// ------ Функция правильной подсветки кода ------- //
function highlight_code($code){
$code = strtr($code,array('<br />'=>"\r\n",'[br]'=>"\r\n",'<br/>'=>"\r\n",'<'=>'<','>'=>'>','&'=>'&','$'=>'$','"'=>'"','''=>"'",'\'=>'`','%'=>'%','^'=>'^'));
if(!strpos($code,'<?') && substr($code,0,2)!='<?'){
$code="<?php\r\n".trim($code);
}
$code = highlight_string($code,true);
$code = strtr($code,array('<br />'=>"\r\n",'[br]'=>"\r\n",'<br/>'=>"\r\n"));
$code = preg_replace('|( {2,})|', "\r\n\1", $code);
$codeline = explode("\r\n", $code);
foreach ($codeline as $line => $string){
if($string!=''){
$ret.='<div style="display:inline-block; width:28px; color:#666">'.($line+1).'</div> '.trim($string).'<br />';
}
}
$code = $ret;
$code = strtr($code,array('$'=>'$',"'"=>''','`'=>'\','%'=>'%','^'=>'^'));
$code = preg_replace('|($[a-z\d_]+)|i','<span style="color:#837731">\1</span>',$code);
return '<div class="php">'.$code.'</div>';
}
?>
Changed: ramzes (11.03.2012 / 23:01)