I was thinking of making an allowance to cater for both situations, in case someone enters <? instead of <?php - the idea came from this date check function I came across:
Code: Select all
# d(d)?m(m)?y(yyy)
$pattern = '(^[0-9]{1,2})'
. '([^0-9a-zA-Z])'
. '([0-9]{1,2})'
. '([^0-9a-zA-Z])'
. '([0-9]{1,4}$)';
if (ereg($pattern, $input, $regs)) {
return validate::verify_date($regs[1], $regs[3], $regs[5]);
}
I'm using this for the time being but it only caters for <?php:
Code: Select all
function getCodeBetweenTags($input) {
$pattern = '^<\?php(.*?)\?>^';
preg_match($pattern, $input, $regs);
return isset($regs[1]) ? $regs[1] : NULL;
} // getCodeBetweenTags()
I'm sure there's only something small to add but I'm a bit stumped!

Thanks for the response.