一點說明,xmlrpc_decode 的回應並不總是陣列。每當 XMLRPC 伺服器返回字串時,xmlrpc_is_fault 就會抱怨它不是陣列。
偵測錯誤的最佳方法是
<?php
$response = xmlrpc_decode($file);
if (is_array($response) && xmlrpc_is_fault($response)) {
throw new Exception($response['faultString'], $response['faultCode']);
}
?>