1

Consider this:

$x=new MyClass;
$x->y=function($name){return "Hi, $name";};

to call the closure I use call_user_func($x->y,'Hasan') that it's not so clean and convenient. Is there any better syntax? Perhaps similar to $x->y("Hasan") (which does not work.)

Handsome Nerd
  • 15,997
  • 20
  • 92
  • 166

0 Answers0