php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #47515 make create_function to execute immediately
Submitted: 2009-02-27 01:49 UTC Modified: 2014-10-12 14:44 UTC
Votes:155
Avg. Score:5.0 ± 0.4
Reproduced:154 of 155 (99.4%)
Same Version:153 (99.4%)
Same OS:153 (99.4%)
From: kexianbin at diyism dot com Assigned: nikic (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.3.1 OS: windows xp
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: kexianbin at diyism dot com
New email:
PHP Version: OS:

 

 [2009-02-27 01:49 UTC] kexianbin at diyism dot com
Description:
------------
I submit a function request:
to make create_function to execute immediately like this:

When could we realize this in php?

create_function('$v', <<<'nowdoc'
echo $v;
nowdoc
)('hello');

I know i can type thus:
$f=create_function('$v', <<<'nowdoc'
echo $v;
nowdoc
);
$f('hello');

even thus:
${!${''}=create_function('$v', <<<'nowdoc'
echo $v;
nowdoc
)}('hello');

but both the 2nd and 3rd are ugly, i need the 1st style.

Expected result:
----------------
Show 'hello'

Actual result:
--------------
Show 'Parse error: parse error'

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-05-15 05:21 UTC] kexianbin at diyism dot com
Currently in php 5.3.0RC3 2009.5.15:

$fun=function($v){echo $v;};
$fun('hello');

but can not do these:

function($v){echo $v;}('hello');
(function($v){echo $v;})('hello');
($fun=function($v){echo $v;})('hello');
 [2010-12-20 09:23 UTC] jani@php.net
-Package: Feature/Change Request +Package: Scripting Engine problem
 [2014-10-12 14:44 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2014-10-12 14:44 UTC] nikic@php.net
Supported in PHP 7.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 14:01:30 2024 UTC