I’m practicing my beginner php skills and would like to know why this script always returns FALSE?
What am i doing wrong?
$namefields = '/[a-zA-Z\s]/';
$value = 'john';
if (!filter_var($value,FILTER_VALIDATE_REGEXP,$namefields)){
$message = 'wrong';
echo $message;
}else{
$message = 'correct';
echo $message;
}
The regexp should be in an options array.
Also, the
should be rather
or
because with the first version I think you match only single-character strings