Doc #54954 [Fbk->Csd]: preg_match() returns zero if an error occurred
| From: | benoit dot chenu at gmail dot com | Date: | Thu, 30 Jun 2011 12:02:50 +0000 |
| Subject: | Doc #54954 [Fbk->Csd]: preg_match() returns zero if an error occurred | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-6776@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=54954&edit=1
ID: 54954
User updated by: benoit dot chenu at gmail dot com
Reported by: benoit dot chenu at gmail dot com
Summary: preg_match() returns zero if an error occurred
-Status: Feedback
+Status: Closed
Type: Documentation Problem
-Package: Documentation problem
+Package: PCRE related
-PHP Version: 5.3.6
+PHP Version: 5.3.3
Block user comment: N
Private report: N
New Comment:
Hi,
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 :
https://bugs.php.net/bug.php?id=52732
The bug fix was published with PHP 5.3.4
Just for information, the tests I was doing :
<?php
$buf = str_repeat('a', 100000).'b';
var_dump(preg_match('/^(.*?)b$/s', $buf));
var_dump(preg_last_error());
Result on PHP 5.3.3 :
int(0)
int(2)
Result on PHP 5.3.6 :
bool(false)
int(2)
I close the bug.
Thanks for your attention.
Previous Comments:
------------------------------------------------------------------------
[2011-06-14 16:36:27] aharvey@php.net
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-05-30 19:34:29] benoit dot chenu at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/manual/en/function.preg-match.php#Return
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.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=54954&edit=1