10
I’m using an API and in some cases a feature of it prints on the screen when there are errors (api errors, not PHP). I happen to call this API via AJAX and it breaks my code since the request ends up generating an invalid JSON.
Is there any way to avoid this in PHP? For example, from a certain chunk of code to another chunk, nothing is printed on the screen?
Something like that:
// desativaria impressão de qualquer coisa aqui
$this->soapClient = new SoapClient($wsdlLink);
$retorno = $this->soapClient->testFunction($params);
// ativaria impressão aqui
In the above case when I call testFunction, instead of saving the error in the $return variable, it prints on the screen.
When accessing a SOAP resource you are calling a pre-set function by the SOAP API developer. It turns out that sometimes testFunction prints the direct error and not as callback.
What to do to solve this problem?
Just to be on the lookout: this question has nothing to do with SOAP or catching errors or exceptions.
– utluiz