第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

Php Json 獲取密鑰

Php Json 獲取密鑰

PHP
斯蒂芬大帝 2023-10-15 17:28:10
我回應(yīng)了這一點(diǎn)并在 ajax 中獲取。$result= $this->mpesa->STKPushQuery($checkoutRequestID, 174379, "bfb279f9aa9bdbcf158e97dd71a467cd2e0c893059b10f78e6b72ada1ed2c919");json 得到的結(jié)果是:{"requestId":"","errorCode":"400.002.02","errorMessage":"Bad Request - Invalid CheckoutRequestID"}現(xiàn)在,在我的 php 代碼中,我需要獲取 errorCode 的鍵,有時(shí)它是 successCode,所以當(dāng)我嘗試這樣做時(shí):if ($result->errorCode=="400.002.02"){    $Data = '{"status":"Submit payment before Checking for it"}';    echo $Data;沒關(guān)系,因?yàn)?errorCode 是在 Json 中找到的。當(dāng)出現(xiàn)成功消息時(shí),即:if ($result->successCode=="0"){    $Data = '{"status":"Payment Successful"}';    echo $Data;}我在第一個(gè)語句中遇到錯(cuò)誤。因?yàn)樵?Json 中找不到 errorCode 所以我實(shí)際需要的是獲取 json 的密鑰(這將是 errorCode 或 successCode),即$mystatusCode== Get the either the errorCode or SuccessCode (key in Json array[1])if ($results->mystatusCode=="400.002.02"){        $Data = '{"status":"Submit payment before Checking for it"}';        echo $Data;}else if ($results->mystatusCode=="0"){$Data = '{"status":"Payment has been processed successfully"}';        echo $Data;}
查看完整描述

1 回答

?
慕沐林林

TA貢獻(xiàn)2016條經(jīng)驗(yàn) 獲得超9個(gè)贊

使用isset將實(shí)現(xiàn)您的目標(biāo):


$mystatusCode = ( isset($result->errorCode) ? $result->errorCode : 

                    ( isset($result->successCode) ? $result->successCode : 

                        NULL

                    )

                );

或者您可以直接在 if 語句中使用它,而不需要?jiǎng)?chuàng)建新的單個(gè)變量:


if (isset($result->errorCode) && $result->errorCode == "400.002.02") {

    ...

}

elseif (isset($result->successCode) && $result->successCode == "0") {

    ...

}


查看完整回答
反對(duì) 回復(fù) 2023-10-15
  • 1 回答
  • 0 關(guān)注
  • 142 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)