{% else-1 %}
Автоматическая подсветка 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 str_replace('&nbsp;', ' ', 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;

?>
0 45 0
0

Нет фото
• 6 апр 2013, 17:28


Как сделать, чтобы работал? На одной странице