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);