Am I being stupid or does preg_match()
not accept global class variables?
class test{
private$username,$usernameValidation;
public function __construct($username){
$this->username=$username;
$this->usernameValidation="/^[a-zA-Z0-9]{0,8}$/";
}
public function validate(){
if(!preg_match($this->usernameValidation,$this->username)){
//failed;
}
}
}
Every time I compile a function like this, it seems to tell me the the expression is empty.
Seems to work as preg_match("/^[a-zA-Z0-9]{0,8}$/",$this->username);
.