#47278 [Bgs]: preg_match behaves different to version 4.4.4
| From: | franklyn dot santana at gmail dot com | Date: | Mon, 02 Feb 2009 23:31:38 +0000 |
| Subject: | #47278 [Bgs]: preg_match behaves different to version 4.4.4 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-133406@lists.php.net to get a copy of this message | ||
ID: 47278
User updated by: franklyn dot santana at gmail dot com
Reported By: franklyn dot santana at gmail dot com
Status: Bogus
Bug Type: PCRE related
Operating System: Windows 2003 Server
PHP Version: 5.2.8
New Comment:
yes, I didn't know there was a PREG_BACKTRACK_LIMIT_ERROR option at
php.ini in php5. I had to set it to 500000 for the script to work.
Thanks people :D
Previous Comments:
------------------------------------------------------------------------
[2009-02-02 23:23:54] jani@php.net
Hint: PREG_BACKTRACK_LIMIT_ERROR
------------------------------------------------------------------------
[2009-02-02 20:46:12] felipe@php.net
Check preg_last_error().
http://docs.php.net/manual/en/function.preg-last-error.php
------------------------------------------------------------------------
[2009-02-02 20:30:13] franklyn dot santana at gmail dot com
I read somewhere (right now I don't remember where) there is problem
with long regular expressions in php5. Is that true? I made the regular
expression shorter, now the script works (with some limitations due to
the short regex).
------------------------------------------------------------------------
[2009-02-02 13:44:58] franklyn dot santana at gmail dot com
Description:
------------
I have a code for url rewrite, I use the preg_match function to
separate the GET parameters.
The code works fine in PHP 4.4.4, I get a matches array with the GET
parameters. But it doesn't work on PHP 5.28, the matches array is
empty.
I was checking the documentation and It seems there are not changes on
this function.
Reproduce code:
---------------
$url="http://localhost/test+param-2009.html";
preg_match("/\/[^+]*\+?[^+]+\++([^-]*)-?([^-]*)-?([^-]*)-?([^-]*)-?([^-]*)-?".
"([^-]*)-?([^-]*)-?([^-]*)-?([^-]*)-?([^-]*)-?([^-]*)-?([^-]*)-?([^-]*)-?([^-]*)-?".
"([^-]*)-?([^-]*)-?([^-]*)-?([^-]*)-?([^-]*)-?([^-]*)\.html/i", $url,
$parameters);
print_r($parameters)
Expected result:
----------------
/*tested on PHP 4.4.4
Array ( [0] => //localhost/test+param-2009.html [1] => param [2] =>
2009 [3] => [4] => [5] => [6] => [7] => [8] => [9] => [10] => [11] =>
[12] => [13] => [14] => [15] => [16] => [17] => [18] => [19] => [20] =>
)
Actual result:
--------------
Array ( )
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=47278&edit=1