I am trying to use pear's text highlighter by searching for tags in an article and highlighting the content between the tags. Something is causing the script to crash with no errors. Error reporting is set to E_ALL. When there are no tags to replace the script completes and outputs the article. Maybe I am missing something obvious but this one has me scratching my head.
<?php
$phpsearch = '/\<\?php(.*?)\\?\>/is';
$sqlsearch = '/\[sql\](.*?)\[\/sql\]/is';
function highlight_sql($matches){
global $sqlsearch;
$matches[0] = preg_replace($sqlsearch, '$1', $matches[0]);
$sql = Text_Highlighter::factory('SQL');
return $sql->highlight($matches[0]);
}
function highlight_php($matches){
$php = Text_Highlighter::factory('php', array('tabsize' => 2));
return $php->highlight($matches[0]);
}
$article = preg_replace_callback($phpsearch, 'highlight_php', $article);
$article = preg_replace_callback($sqlsearch, 'highlight_sql', $article);
?>