strstr - 与XML响应无法正常工作(符号)

时间:2016-12-22 12:36:35

标签: php strstr

Michael要求编辑的帖子。

$Response = $soapClient->__getLastResponse();
$pos = strpos($Response, ">");
echo substr($Response, $pos+1);
// Returns soap:ReceiverServer was unable to process request. ---> Product already exists

$Response = $soapClient->__getLastResponse();
$converted = (string)$Response
$pos = strpos($converted, ">");
echo substr($converted, $pos+1);
// Returns soap:ReceiverServer was unable to process request. ---> Product already exists

我正在使用API​​并希望将响应用作错误消息。响应如下所示:

soap:ReceiverServer was unable to process request. ---> Product already exists

我正在尝试删除Product之前的所有内容,因此我只是向用户显示错误消息。但是,当我使用它时,我得到以下回报。

>soap:ReceiverServer was unable to process request. ---> Product already exists

这是我目前正在使用的代码。有人有什么建议吗?

$Response = $soapClient->__getLastResponse();
echo $Response;
// Shows the below
// soap:ReceiverServer was unable to process request. ---> Product already exists

$test =  strstr($Response, '>');
echo '<br>'
echo $test;
// Shows the below
// >soap:ReceiverServer was unable to process request. ---> Product already exists

1 个答案:

答案 0 :(得分:0)

$http({
 method: 'GET',
 url: url,
 headers: { 'Access-Control-Request-Headers': undefined },
})