KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I would like to be able to call a closure that I assign to an object's property directly without reassigning the closure to a variable and then calling it. Is this possible? The code below doesn't work and causes Fatal error: Call to undefined method stdClass::callback() . $obj = new stdClass(); $obj->callback = function() { print "HelloWorld!"; }; $obj->callback();
Tags (comma-separated)
Save Edits
Cancel