class Foo { public function bar($x) { echo $x; } } function xyz($cb) { $value = rand(1,100); call_user_func($cb, $value); } $foo = new Foo; xyz( array($foo, 'bar') ); 

Why is the bar method called? I would understand if something like this was written so call_user_func ($ foo-> bar, $ value);



    2 answers 2

    1. We look call_user_func We see that the first parameter is callable.

    2. See what a "callable" is .

    Or the insides of the implementation of interest? Then it is better to look at the source.

    • Thank you already figured out. I did not really know the possibilities of call_user_func - koza4ok

    Because such a function call_user_func , read about its arguments.