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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 14:01:36 2025 UTC