|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #54954 preg_match() returns zero if an error occurred
Submitted: 2011-05-30 19:34 UTC Modified: 2011-06-30 08:02 UTC
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: benoit dot chenu at gmail dot com Assigned:
Status: Closed Package: PCRE related
PHP Version: 5.3.3 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: benoit dot chenu at gmail dot com
New email:
PHP Version: OS:


 [2011-05-30 19:34 UTC] benoit dot chenu at gmail dot com
From manual page: Values

A bug was already opened (#51741) about this but not treated. If an error occurs (like reaching pcre.backtrack_limit), preg_match doesn't return FALSE as described in the documentation but returns 0.

It should be nice to update the documentation.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-06-14 16:36 UTC]
-Status: Open +Status: Feedback
 [2011-06-14 16:36 UTC]
What version of PHP are you getting integer 0 back from preg_match() when the backtrack limit is hit? Everything I have to hand is returning boolean false, which is what I'd expect.
 [2011-06-30 08:02 UTC] benoit dot chenu at gmail dot com
-Status: Feedback +Status: Closed -Package: Documentation problem +Package: PCRE related -PHP Version: 5.3.6 +PHP Version: 5.3.3
 [2011-06-30 08:02 UTC] benoit dot chenu at gmail dot com

I was testing on 5.3.3 (and not 5.3.6). I made a mistake when reporting. I change the version to 5.3.3 in bug's description.

I've just tested on latest version (5.3.6) and the problem is resolved. So this is not a documentation problem but a bug. I also change the package and bug type in description.

I finally found the bug report which was resolve the problem :

The bug fix was published with PHP 5.3.4

Just for information, the tests I was doing :

$buf = str_repeat('a', 100000).'b';
var_dump(preg_match('/^(.*?)b$/s', $buf));

Result on PHP 5.3.3 :

Result on PHP 5.3.6 :

I close the bug.
Thanks for your attention.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Sep 20 15:03:37 2021 UTC