Edit report at http://bugs.php.net/bug.php?id=51741&edit=1
ID: 51741 Updated by: m...@php.net Reported by: jordi dot salvat dot i dot alabart at gmail dot com Summary: preg_match returns zero if it hits backtracking limit -Status: Open +Status: Bogus Type: Bug Package: PCRE related Operating System: Ubuntu PHP Version: 5.3SVN-2010-05-04 (SVN) New Comment: Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. > Note that pcretest does report an error in this same case As can be queried with preg_last_error(). Previous Comments: ------------------------------------------------------------------------ [2010-05-04 20:32:41] jordi dot salvat dot i dot alabart at gmail dot com Description: ------------ According to the documentation, pcre_match should return FALSE on error: >From http://docs.php.net/manual/en/function.preg-match.php : << Return Values preg_match() returns the number of times pattern matches. That will be either 0 times (no match) or 1 time because preg_match() will stop searching after the first match. preg_match_all() on the contrary will continue until it reaches the end of subject. preg_match() returns FALSE if an error occurred. >> Instead, it returns 0 (integer zero) -- see Felipe's comment on http://bugs.php.net/bug.php?id=51663&edit=2 for a check. Note that pcretest does report an error in this same case: $ pcretest PCRE version 7.8 2008-09-05 re> /(.+)+:/ data> \q10a:bbb Error -8 data> Test script: --------------- <? ini_set('pcre.backtrack_limit', 10); print_r( preg_match('/(.+)+:/','a:bbb') === FALSE ? 'pass' : 'fail' ); Expected result: ---------------- pass Actual result: -------------- fail ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=51741&edit=1