Originally Posted by Fou-Lu
The only reason to check beyond a loose true and false is to determine if the pattern failed (or as of 5.3.6, that the offset is > the length provided). There's no reason why you cannot make use of an elseif should you need to know if the pattern is bad:
if (($result = preg_match('...', $var, $matches)) === false)
// bad pattern
else if ($result)
// no matches.
Although realistically you should catch a bad failure during development as it will trigger a warning.
What do you mean by a "bad pattern"?
Do you mean invalid Regex syntax?
Or is it like a "logical error" with my Regex?
If it deals with bad syntax, then is that really necessary, even in development?