【问题标题】:Get specific value from Object in PHP从 PHP 中的对象获取特定值
【发布时间】:2010-06-26 05:15:13
【问题描述】:
<?php

$a['registrationID']="*******";
$a['password']="******";
$a['smsPort']=7424;
$a['msgID']=0;

$soap_url='http://localhost/WebService_GP_ADP_BizTalk_SMS_Orchestrations.wsdl';
$soap = new SoapClient($soap_url);

$response=$soap->getReceivedSMS( array ("ReceiveSMSRequest" => $a) );
print_r($response);
?>

这会返回:

stdClass Object
(
    [ReceiveSMSResponse] => stdClass Object
        (
            [msgID] => 20100620202512840316
            [senderMSISDN] => 1732172782
            [timeStamp] => 6/20/2010 8:25:14 PM
            [msgContent] => testing
            [sourcePort] => 7424
        )

)

如何获取对象的不同部分并将它们分别放入字符串中? 例如我想要类似 $msgcontent= //whatever is in [msgcontent]

【问题讨论】:

    标签: php string object


    【解决方案1】:

    使用-&gt; 运算符。在您的具体示例中:

    print($response->ReceiveSMSResponse->msgContent);
    

    欲了解更多信息,请参阅:http://www.php.net/manual/en/language.oop5.properties.php

    【讨论】:

    • 非常感谢,我生气了,这是一个非常明确的问题,答案很完美
    猜你喜欢
    • 1970-01-01
    • 2017-11-22
    • 1970-01-01
    • 2018-11-05
    • 1970-01-01
    • 2017-01-28
    • 2018-05-22
    • 2010-11-08
    • 1970-01-01
    相关资源
    最近更新 更多