php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #12405 The result of create_function should be accepable to the parser
Submitted: 2001-07-26 13:14 UTC Modified: 2010-12-14 11:51 UTC
From: ben-php at bacarisse dot btinternet dot co dot uk Assigned: jani (profile)
Status: Closed Package: *General Issues
PHP Version: 4.0.6 OS: Linux (but I think all)
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ben-php at bacarisse dot btinternet dot co dot uk
New email:
PHP Version: OS:

 

 [2001-07-26 13:14 UTC] ben-php at bacarisse dot btinternet dot co dot uk
While trying to build a set of higher-order search and 
match functions, I came across the "null at the front of 
the lambda name" refered to in bug #10721.

It would ne very neat if one could write:

function _not_($f) {
  return create_function('$x', "return !$f(\$x);");
}

and so on for _and_ and _or_(with two function args).  
Once a set of primitive match functions are defined you 
can then define complex criteria.  However, the parser 
rejects the names produced create_function.

The following works but it clearly yucky:

function f_not($f) {
  $f = substr($f, 1);
  return create_function('$x',
    "return !call_user_func(chr(0).'$f', \$x);");
}

For these lambdas to be true closures, they should be 
callable from other created functions.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-14 11:51 UTC] jani@php.net
-Status: Open +Status: Closed -Package: Feature/Change Request +Package: *General Issues -Assigned To: +Assigned To: jani
 [2010-12-14 11:51 UTC] jani@php.net
We have closures now since PHP 5.3.0
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 15:01:33 2024 UTC