Problem with regex and highlight_string...
Posted: Wed Jul 09, 2008 7:33 pm
Hi all, I'm trying to use highlight_string within preg_replace to do some PHP highlighting. I am getting the following error:
And heres the example PHP code I'm trying to shove through it:
I have no idea how to resolve this, any ideas folks?
Heres the code:Parse error: syntax error, unexpected '<' in C:\xampp\htdocs\phpextra\pages\news\read.php(17) : regexp code on line 1
Fatal error: preg_replace() [<a href='function.preg-replace'>function.preg-replace</a>]: Failed evaluating code: <code><span style="color: #000000"> include CLASSES.\'/breadcrumb.class.php\'; $breadcrumb = new breadcrumb; $breadcrumb->add_breadcrumb(\'Home\',\'/\'); $breadcrumb->add_breadcrumb(\'News\',\'/news/\'); $breadcrumb->add_breadcrumb($news_data[\'title\'],\'\'); $page_breadcrumb = $breadcrumb->show_breadcrumb(); </span> </code> in C:\xampp\htdocs\phpextra\pages\news\read.php on line 17
Code: Select all
$main_content = preg_replace('#\[php\](.*?)\[\/php\]#ise', highlight_string(stripslashes('$1'),true), $main_content);Code: Select all
include CLASSES.'/breadcrumb.class.php';
$breadcrumb = new breadcrumb;
$breadcrumb->add_breadcrumb('Home','/');
$breadcrumb->add_breadcrumb('News','/news/');
$breadcrumb->add_breadcrumb($news_data['title'],'');
$page_breadcrumb = $breadcrumb->show_breadcrumb();