|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
Patchespreg_match_false_on_error (last revision 2010-10-07 13:39 UTC by slugonamission at gmail dot com)Bug_52732_preg_match_false_on_error (last revision 2010-10-07 13:37 UTC by slugonamission at gmail dot com) Pull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-11-06 19:32 UTC] felipe@php.net
[2010-11-06 19:32 UTC] felipe@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: felipe
[2010-11-06 19:32 UTC] felipe@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 04 21:00:01 2025 UTC |
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