Mhtml
04-25-2003, 08:54 PM
I'm having a load of trouble trying to get this script to work.
function phpcode($str)
{
$str = str_replace('\\"','"',$str);
$str = highlight_string($str,1);
return $str;
}
$message = preg_replace('/\[php\](.*?)\[\/php\]/ise', "phpcode('\\\\$1')", $message);
It is supposed to do exactly as the [ php ] tags in this forum do but it just doesn't seem to want to do it sometimes.
It doesn't seem to handle \ very well, because if you enter " in the message field of the form and submit it gets turned into \" and it comes up with an error saying unexpected character \" !! But what's odd is it is always the last quote, the first quotes get changed but the second qoute in the string doesn't it's left as \". So there is code there to turn \" into ' " ' but it just doesn't seem to work more than 50% of the time.
function phpcode($str)
{
$str = str_replace('\\"','"',$str);
$str = highlight_string($str,1);
return $str;
}
$message = preg_replace('/\[php\](.*?)\[\/php\]/ise', "phpcode('\\\\$1')", $message);
It is supposed to do exactly as the [ php ] tags in this forum do but it just doesn't seem to want to do it sometimes.
It doesn't seem to handle \ very well, because if you enter " in the message field of the form and submit it gets turned into \" and it comes up with an error saying unexpected character \" !! But what's odd is it is always the last quote, the first quotes get changed but the second qoute in the string doesn't it's left as \". So there is code there to turn \" into ' " ' but it just doesn't seem to work more than 50% of the time.