View Single Post
Old 10-07-2012, 11:23 PM   PM User | #4
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,741
Thanks: 4
Thanked 2,465 Times in 2,434 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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:
PHP Code:
if (($result preg_match('...'$var$matches)) === false)
{
    
// bad pattern
}
else if (
$result)
{
    
// matches
}
else
{
    
// no matches.

Although realistically you should catch a bad failure during development as it will trigger a warning.
Fou-Lu is offline   Reply With Quote