From: Operating system: Any PHP version: 5.3.3 Package: PCRE related Bug Type: Bug Bug description:Docs say preg_match() returns FALSE on error, but it returns int(0)
Description: ------------ The documentation states that preg_match() will return the number of matches (0 or 1) or bool(false) on error. The latter doesn't happenâpreg_match() is returning int(0) when an error occurs. Test script: --------------- <?php // Ensure we hit the backtrack limit ini_set('pcre.backtrack_limit', 1); // See http://us.php.net/preg_last_error $ret = preg_match('/(?:\D+|<\d+>)*[!?]/', 'foobar foobar foobar'); echo 'Return value is '; var_dump($ret); if ($ret === false) { echo '$ret is false; preg_last_error() says: ' . preg_last_error() . "\n"; } else { echo '$ret is not false; preg_last_error() says: ' . preg_last_error() . "\n"; } Expected result: ---------------- Return value is bool(false) $ret is false; preg_last_error() says: 2 Actual result: -------------- Return value is int(0) $ret is not false; preg_last_error() says: 2 -- Edit bug report at http://bugs.php.net/bug.php?id=52732&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=52732&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=52732&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=52732&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=52732&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52732&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=52732&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=52732&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=52732&r=needscript Try newer version: http://bugs.php.net/fix.php?id=52732&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=52732&r=support Expected behavior: http://bugs.php.net/fix.php?id=52732&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=52732&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=52732&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=52732&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52732&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=52732&r=dst IIS Stability: http://bugs.php.net/fix.php?id=52732&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=52732&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=52732&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=52732&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=52732&r=mysqlcfg