preg_last_error() returns No Error on preg_match() Failure
A question came up on a mailing list that I subscribe to that I thought interesting. Consider this code: <?php $result = preg_match("/href='(.*)", 'blah'); $error = preg_last_error(); if($error === PREG_NO_ERROR) { echo "No Error\n"; } else { echo "An Error Occurred\n"; } var_dump($result); The output is: Warning: preg_match(): No ending delimiter '/' found in /var/www/preg_test.php on line 2 No Error bool(false) As you can see the pattern passed to preg_match is invalid as it is… continue reading.