SoapClient error fallback in PHP SoapClient error fallback in PHP php php

SoapClient error fallback in PHP


This has already been discussed :

Rasmus himself proposed the following solution:

<?php  try {      $x = @new SoapClient("non-existent.wsdl",array("exceptions" => 1));  } catch (SoapFault $E) {      echo $E->faultstring; }  echo "ok\n";


See this topic How do I catch a PHP Fatal Error

Basically you cant recover from a fatal error but you can provide a better experience to the user when registering a shutdown function

register_shutdown_function('handleShutdown');function handleShutdown(){    $error = error_get_last();    if($error !== NULL){        echo "Sorry for the inconvenience, an error just occurred.";    }}