|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-03-18 23:27 UTC] felipe@php.net
[2009-03-19 08:10 UTC] al dot james at gmail dot com
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 01 16:00:02 2025 UTC |
Description: ------------ If I assign an instance of the Closure object as a property of an object, I would expect to be able to execute that property as a function. E.g. $o = new stdClass; $o->test = function(){ echo "Executing function"; }; I would expect this to work: $o->test(); However, it does not. This does: call_user_func($o->test); The $o->test() syntax is more concise and in keeping with other languages with such features. Reproduce code: --------------- $o = new stdClass; $o->test = function(){ echo "Executing function"; }; $o->test(); Expected result: ---------------- Executing function Actual result: -------------- PHP Fatal error: Call to undefined method stdClass::test()