PHP - 将错误替换为警告(使用soap)

I am using SOAP to get data from some server (data coming in .xml) . But sometimes SOAP server is down and I need to display some error message instead of :

Warning: simplexml_load_string(): Entity: line 2: parser error : Start tag expected, '<' not found in /var/www/class/data2.php on line 619 Warning: simplexml_load_string(): in /var/www/class/data2.php on line 619 Warning: simplexml_load_string(): ^ in /var/www/class/data2.php 

My code is:

$client = new SOAPClient ( 'link.wsdl' ); // initiate new SoapClient
$password ['_'] = 'PASSWORD'; // password for authenticate_user function in SoapHeader
$encoded = new SoapVar ( $password, SOAP_ENC_OBJECT ); // make SoapVariable out of $password
$header = new SoapHeader ( 'http://soapinterop.org/echoheader/', 'authenticate_user', $encoded ); // put authenticate_user method, and password in header
$client->__setSoapHeaders ( $header ); // set SoapHeader
$response = $client->get_details ($this->vin); // calling get_details with the vin given in the form field
$xml = simplexml_load_string ( $response ); // converting the response string to xml
$json = json_encode ( $xml ); // converting to an array in to easy steps (step 1)
$array = json_decode ( $json, TRUE ); // step 2

What I want: Replace Warning message with something like: "This service is temporary unavaliable"

After

$xml = simplexml_load_string ( $response );

check if

$xml === false

and set the error message accordingly

http://php.net/manual/en/function.simplexml-load-string.php

As you can read in manual the simplexml_load_string function:

Returns an object of class SimpleXMLElement with properties containing the data held within the xml document, or FALSE on failure.

So simply check if it fails and if it does echo your This service is temporary unavaliable

To get rid of this warning consider to ini_set('display_errors', '0'); on production