|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-01-01 22:50 UTC] jani@php.net
-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: *
[2021-10-21 12:02 UTC] cmb@php.net
-Status: Open
+Status: Wont fix
-Assigned To:
+Assigned To: cmb
[2021-10-21 12:02 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 15:00:01 2025 UTC |
Description: ------------ 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'; } $foo(); Works fine. It would be nice to be able to do something like function foo() { echo 'bar'; } $foo = &foo; $foo(); And ultimately, override the defined function: function foo() { echo 'bar'; } $oldFoo = &foo; foo = function() use ($oldFoo) { $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.