|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #49100 Reference of native function in variable (function pointers)
Submitted: 2009-07-29 14:58 UTC Modified: 2011-01-01 22:50 UTC
Avg. Score:2.0 ± 1.7
Reproduced:2 of 3 (66.7%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: tom at r dot je Assigned:
Status: Open Package: Scripting Engine problem
PHP Version: * OS: *
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: tom at r dot je
New email:
PHP Version: OS:


 [2009-07-29 14:58 UTC] tom at r dot je
With the intorduction of closures it would be nice to be able to have some control over native functions for example:

$foo = function() { 
echo 'bar';


Works fine. 

It would be nice to be able to do something like

function foo() {
echo 'bar';

$foo = &foo;

And ultimately, override the defined function:

function foo() {
echo 'bar';

$oldFoo = &foo;
foo = function() use ($oldFoo) {
   echo 'bar';

foo(); // will print 'foobar';

There are several uses for this, just look at the way closures are commonly used in javascript. It's really useful for debugging, as a function can be substituted easily.

Though this probably isn't possible due to the clear distinction php makes between functions and variables. 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-01 22:50 UTC]
-Summary: Reference Native Function in variable (function pointers) +Summary: Reference of native function in variable (function pointers) -Package: Feature/Change Request +Package: Scripting Engine problem -Operating System: Windows Vista +Operating System: * -PHP Version: 5.3.0 +PHP Version: *
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Sep 20 14:03:38 2021 UTC