(PHP) SoapClient class object could not be converted to string

This code works great:


$result = $client->__call("optionalInfo", array(
    new SoapParam("...", "client"),
    new SoapParam("...", "add_code"))
);

      

When I try to abstract it a bit to make the script reusable, I get this error:

Allowable fatal error: Object of class SoapClient cannot be converted to string

Broken code:



$params = array( new SoapParam($client, "client"),
             new SoapParam($add_code, "add_code")
);
$result = $client->__call($functionName, $params);


      

The last reason is the problem.

+1


source to share


1 answer


Are you sure you want to send the SoapClient interface as an argument to call a function on the same object?



new SoapParam($client, "client")

      

+2


source







All Articles