dustinnoe Posted October 19, 2007 Share Posted October 19, 2007 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); ?> Quote Link to comment https://forums.phpfreaks.com/topic/73897-solved-pear-text_highlighter/ Share on other sites More sharing options...
dustinnoe Posted October 19, 2007 Author Share Posted October 19, 2007 Oops! I didn't realize I was still running php4 on this machine. Upgraded to php5 and everything works great. Quote Link to comment https://forums.phpfreaks.com/topic/73897-solved-pear-text_highlighter/#findComment-372915 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.