I'm doing some variable variables, using classes, like so:
class UrlScope {
function UrlScope() {
foreach ($_GET as $key=>$val) {
$lkey = strtolower($key);
$ukey = strtoupper($key);
$this->$lkey = $val;
$this->$ukey = $val;
$this->$key = $val;
}
}
}
I'm wanting to add some code to verify that the name is a valid variable using the regex on the php manual page for valid variable names like so:
function is_validvariablename($input) {
if (ereg('[a-zA-Z\x7f-\xff][a-zA-Z0-9\x7f-\xff]*',$input) ) {
return true;
}
else {
return false;
}
}
However, calling is_validvariablename("blah"), which should be ok, gives me:
Warning: ereg(): REG_ERANGE
And returns 0 regardless of what I pass in.
I've tried using preg_match() too, and it fails with:
Warning: Unknown modifier '['
And returns 0 regardless of what I pass in.
Any help would be appreciated.