object(stdClass)#3 (12) {
["responseCode"]=> string(4) "0000"
["orderId"]=> string(6) "456456"
["storeId"]=> int(5591)
["storeName"]=> string(26) "rr bb"
["paymentToken"]=> string(7) "1784388"
["transactionId"]=> string(6) "6456456"
["transactionStatus"]=> string(7) "PENDING"
["transactionAmount"]=> float(6945)
["transactionDateTime"]=> string(29) "2018-07-31T12:46:46.000+05:00"
["paymentTokenExiryDateTime"]=> string(29) "2018-08-04T12:46:46.393+05:00"
["msisdn"]=> string(11) "0345555"
["paymentMode"]=> string(3) "OTC"
}
我有一个Soap API
函数和一个变量,我使用print_r
命令接收了上述数据
现在我想要一个信号数据paymentToken
,该信号如何在PHP
中访问:
<?php echo $var1->paymentToken; ?>
<?php echo $var1['paymentToken']; ?>
答案 0 :(得分:1)
只需:
$OpenAPI = new OpenAPI;
$var = $OpenAPI->inquireTransaction();
echo $var->paymentToken;
此处$ object应该具有上述给定数据。
答案 1 :(得分:0)
您可以像这样在stdClass中访问公共可访问属性:
$object->attribute;
您可以像这样访问数组中的值:
$object['attribute'];
(您还可以将stdClass转换为这样的数组:)
$attribute = (array)$myStdClass['attribute'];