Convert $test
in string like this:
$str_test = (string) $test;
OR Use only this regex
(XtzTy|bb9c3)
without ~
OR
/(XtzTy|bb9c3)/
Domanda
I have a very weird error from preg_match command.
If I set the $test as (for example) $test = 'XtzTy';
it's working perfectly.
BUT
since $test is not static it's not working even if the value IS XtzTy
So I thought to convert it to string so I was using
$test= settype($test, 'string');
but it still NOT working !!!
This is my EXTREMELY SIMPLE preg_match compare tool :
if (preg_match('~(XtzTy|bb9c3)~',$test)) {
echo 'String Found!';
}
If both of them is STRING and the value of $test is XtzTy
AND converted to string why it's not working ?
Soluzione
Convert $test
in string like this:
$str_test = (string) $test;
OR Use only this regex
(XtzTy|bb9c3)
without ~
OR
/(XtzTy|bb9c3)/