略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: xmlrpc_is_fault

2024-04-28

xmlrpc_is_fault

(PHP 4 >= 4.3.0, PHP 5, PHP 7)

xmlrpc_is_faultDetermines if an array value represents an XMLRPC fault

说明

xmlrpc_is_fault(array $arg): bool
警告

此函数是实验性的。此函数的表象,包括名称及其相关文档都可能在未来的 PHP 发布版本中未通知就被修改。使用本函数风险自担。

参数

arg

Array returned by xmlrpc_decode().

返回值

Returns true if the argument means fault, false otherwise. Fault description is available in $arg["faultString"], fault code is in $arg["faultCode"].

范例

See example by xmlrpc_encode_request().

参见

add a noteadd a note

User Contributed Notes 1 note

up
1
angelo at at dot com
11 years ago
A note, response from xmlrpc_decode is not always an array. Whenever the XMLRPC server returns a string, xmlrpc_is_fault will complain about not being an array.

Best way to detect errors is

<?php

   
    $response
= xmlrpc_decode($file);

    if (
is_array($response) && xmlrpc_is_fault($response)) {
        throw new
Exception($response['faultString'], $response['faultCode']);
    }
   
?>

官方地址:https://www.php.net/manual/en/function.xmlrpc-is-fault.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3