views:

199

answers:

2

Hi all,

consider this simple scenario:

$this->method($arg1, $arg2);

Solution:

call_user_func_array(array($this,'method'), array($arg1, $arg2));

consider this scenario:

$this->object->method($arg1, $arg2);

Should this solution work?

call_user_func_array(array($this->object,'method'), array($arg1, $arg2));

Or should this work?

    call_user_func_array(array($this, 'object','method'), array($arg1, $arg2));

Edit: Will try/catch works for SOAP exception, triger while using call_user_func?

  try {
 $soap_res = call_user_func_array(array($this->service,'getBanana'), array(0, 10));
} catch (SoapFault $fault) {
 die($fault->faultstring)
}
+7  A: 

This should work:

call_user_func_array(array($this->object,'method'), array($arg1, $arg2));

The first argument is a callback type, containing an object reference and a method name.

Greg
+1  A: 

I reckon this is a question/answer site... but damn, the notion of running both solutions to see which one works never occured to you?

Mario