$document = "<html><head></head><body><b>Hi</b><?php echo \"lol\";?><br></body></head></html>"; function shighlight($document) { // Преобразуем угловые скобки для отображения HTML-тегов $document = str_replace("<", "<", $document); $document = str_replace(">", ">", $document); // Преобразуем теги PHP <?php и ? > $tegs = array("'<\?php'i","'<\?'i","'\?>'i"); $replace = array( "<font color=#95001E><?php</font>", "<font color=#95001E><?</font>", "<font color=#95001E>?></font>",); $document = preg_replace($tegs, $replace, $document); echo($document); } shighlight($document); I just can not understand why it does not process the template, it does not produce errors.