Concerning my code below:
I'm sorry, I completely forgot about str_ireplace being for PHP 5 for some reason. Also, there was another error I missed (too many late nights ;)). Here's the corrected code:
<?php
function highlight_code($code, $inline=false, $return=false) {
(string) $highlight = "";
if ( version_compare(PHP_VERSION, "4.2.0", "<") === 1 )
{
ob_start(); highlight_string($code);
$highlight = ob_get_contents(); ob_end_clean(); }
else
{
$highlight=highlight_string($code, true);
}
if ( $inline === true )
$highlight=preg_replace("/<code>/i","<code class=\"inline\">",$highlight);
else
$highlight=preg_replace("/<code>/i","<code class=\"block\">",$highlight);
if ( $return === true )
{
return $highlight;
}
else
{
echo $highlight;
}
}
?>