PHP SoapFault not caught by exception handlers

后端 未结 2 1571
太阳男子
太阳男子 2020-12-31 02:29

I am new to PHP exception handling and SOAP. For some reason I cannot catch a SoapFault. I don\'t know why. The soap server is not mine.

try { 
    $contact_         


        
2条回答
  •  失恋的感觉
    2020-12-31 03:16

    The code you've submitted appears to be correct. Here's the only thing that comes to my mind.

    With that said, if the code is located inside a class that define a namespace, you code will not work as it will try to reference Exception as \namespace\Exception which does not exist. "Passive" references such as those in catch clauses or instanceof expressions are permitted because the missing class could be loaded later.

    For it to work, you have to prefix the class name with a slash (i.e. \Exception) to tell PHP to use PHP from the global space (or root if you want to call it that) (PHP) as opposed to your namespace;

    
    

    You can find lots of information about namespaces here: http://php.net/manual/en/language.namespaces.php.

提交回复
热议问题