Ack! Meant to use substr rather then strpos, doh! Will teach me to write blind code :-)
Blah. It's all wrong anyway as I was assuming one to add surrounding tags for the code but that is of course not correct! Not sure where that came from, need to do more eval()ating I guess :-)
In honor of finishing the job :
function evalCode ($code,$type='php')
{
if ($type == 'php') {
eval($code);
}
elseif ($type == 'html') {
eval("?>$code");
}
else {
eval($code);
}
} // EOF;
$a = '<h3>foo</h3>bar';
$b = 'print "<h3>foo</h3>bar";';
evalCode($a,'html');
evalCode($b,'php');
Nothing special or all that useful but had to clear up the other VERY useless code. There must be a way for eval to know how to evaluate ... although this may be one of those "yo php user, don't be lazy, don't rely on php reading your mind, it is inefficient to do so." I am lazy. At somepoint playing with ob_* functions will prove fruitful for this venture.
Bottom line : As stated, prepending ?> works for html :-)