Php 无法从对象获取数组转换数据
我有一个对象响应类型Php 无法从对象获取数组转换数据,php,arrays,codeigniter,object,Php,Arrays,Codeigniter,Object,我有一个对象响应类型 FirstGivingCreditCardDonationResponse Object ( [transactionId:FirstGivingCreditCardDonationResponse:private] => a-10d28597b9dc524bae6a02 [rawResponse:FirstGivingCreditCardDonationResponse:private] => a-10d28597b9dc524bae6a020 [
FirstGivingCreditCardDonationResponse Object ( [transactionId:FirstGivingCreditCardDonationResponse:private] => a-10d28597b9dc524bae6a02
[rawResponse:FirstGivingCreditCardDonationResponse:private] => a-10d28597b9dc524bae6a020
[responseCode:FirstGivingCreditCardDonationResponse:private] => 201 )
转换为数组后,它将变为
Array ( [FirstGivingCreditCardDonationResponsetransactionId] => a-b15ed981602d994d87718e [FirstGivingCreditCardDonationResponserawResponse] => a-b15ed981602d994d87718e0 [FirstGivingCreditCardDonationResponseresponseCode] => 201 )
当我从数组中获取这些值时,它会显示
A PHP Error was encountered
Severity: Notice
Message: Undefined index: FirstGivingCreditCardDonationResponseresponseCode
Filename: controllers/campaign.php
Line Number: 132
假设您在这里使用这个类: 我不会将对象转换为数组,只是通过公共方法访问其私有属性:
$ResponseObject::getTransactionID();
$ResponseObject::getRawResponse();
$ResponseObject::getResponseCode();
您可能需要包含该标题来定义类,以便使用它从何处获取$ResponseObject?抱歉,
$ResponseObject
只是假设在您作为响应接收对象时将其分配给PHP变量。我需要更多的上下文来真正帮助您,因为遇到了一个PHP错误严重性:注意消息:未定义属性:活动:$transactionId文件名:firstgiving/FirstGivingCreditCardDonationResponse.PHP行号:42是否包含该SDK?该项目的自述文件提供了有关如何使用其API的更多信息$firstGivingCreditCardDonationResponse=$firstGivingApiClient->makeCreditCardDonation($捐赠,$creditCardPayment,$服务器['REMOTE_ADDR')
是获取响应对象的行,因此可以使用上述方法访问数据