php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51845 preg_replace_callback anonymous function issue
Submitted: 2010-05-17 18:30 UTC Modified: 2010-08-09 00:56 UTC
From: jerry at jmweb dot net Assigned: felipe (profile)
Status: Closed Package: Unknown/Other Function
PHP Version: 5.3.2 OS: Linux
Private report: No CVE-ID: None
 [2010-05-17 18:30 UTC] jerry at jmweb dot net
Description:
------------
Using an anonymous function as argument #2 in preg_replace_callback issues the following warning:
preg_replace_callback() [function.preg-replace-callback]: Requires argument 2, '', to be a valid callback

This warning was not thrown previously using PHP 5.3.1

Test script:
---------------
echo preg_replace_callback('~-([a-z])~', function ($match) {
    return strtoupper($match[1]);
}, 'hello-world');

Expected result:
----------------
helloworld

Actual result:
--------------
hello-world + warning

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-05-19 15:12 UTC] mike@php.net
-Status: Open +Status: Feedback
 [2010-05-19 15:12 UTC] mike@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

Works here.
 [2010-08-09 00:56 UTC] felipe@php.net
-Status: Feedback +Status: Closed -Assigned To: +Assigned To: felipe
 [2010-08-09 00:56 UTC] felipe@php.net
'helloWorld' is what you get on 5.3.3.

Thanks.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 04 06:01:35 2024 UTC