Edit report at http://bugs.php.net/bug.php?id=52732&edit=1

 ID:                 52732
 Updated by:         fel...@php.net
 Reported by:        drew at dinomite dot net
 Summary:            Docs say preg_match() returns FALSE on error, but it
                     returns int(0)
-Status:             Open
+Status:             Closed
 Type:               Bug
 Package:            PCRE related
 Operating System:   Any
 PHP Version:        5.3.3
-Assigned To:        
+Assigned To:        felipe
 Block user comment: N

 New Comment:

This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

Thanks for the patch!


Previous Comments:
------------------------------------------------------------------------
[2010-11-06 19:32:12] fel...@php.net

Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&revision=305132
Log: - Fixed bug #52732 (Docs say preg_match() returns FALSE on error,
but it returns int(0))
  patch by: slugonamission at gmail dot com

------------------------------------------------------------------------
[2010-08-29 19:42:25] drew at dinomite dot net

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 this bug report at http://bugs.php.net/bug.php?id=52732&edit=1

Reply via email to