SoapClient error fallback in PHP

对着背影说爱祢 提交于 2019-11-30 12:56:56

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";
Andris

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.";
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!