Подсветка PHP кода

<?php

$text = htmlspecialchars('[code]

echo\' ky\';[/code]', ENT_QUOTES, 'UTF-8');

function highlight_code1($code)

{

$code = trim($code[1]);

if(!preg_match('#^&lt;\?(.+?)\?&gt;$#', $code))

$code='&lt;?php

'.$code.'

?&gt;';

 

return $code;

}

function highlight_code2($code)

{

return highlight_string(html_entity_decode($code[0], ENT_QUOTES, 'UTF-8'),1);

}

 

$text = preg_replace_callback('#\[code\](.+?)\[/code\]#sui' , 'highlight_code1', $text);

$text = preg_replace_callback('#&lt;\?(.+?)\?&gt;#sui', 'highlight_code2', $text);

echo $text;

?>

»Скачать в формате .ТХТ
»Скачать в формате .ZIP
»На главную
© allPHP.pp.ru