Jump to content

Blog Code


allistera

Recommended Posts

Hey there, I am using geshi to text highlight PHP code that is surronded with [ code] tags. Here is my current function:

 

function highlightCode($source, $language) {
$geshi =& new GeSHi($source, $language);
echo $geshi->parse_code();
}

function article_bbcode ($str) {
$str = preg_replace('/\[code\=([a-z]+)\](.*?)\[\/code\]/ies', "highlightCode(\"$2\", \"$1\")", $str);
return $str;
}

 

The code outputs fine and is colored fine, but the only problem is that all varables are removed and not outputed, example:

When

$var = 1;[ /code] goes throught this comes out:
[code=php:0]
= 1;

 

Thanks for all help.

Link to comment
https://forums.phpfreaks.com/topic/102635-blog-code/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.