鍍金池/ 問答/PHP  HTML/ thinkphp怎么取返回的值?

thinkphp怎么取返回的值?

利用curl進(jìn)行模擬登錄后返回了一組數(shù)據(jù)
圖片描述

我應(yīng)該怎樣去獲取data下面的那個st值?

$info = $this->curl_post_https('https://xxx/Home/logindo?fromSite=6',$cookie = tempnam('E:\wwwroot\tp5\public','cookie'),$data);
return $info['content']['data']['st'];

這樣直接報錯:Illegal string offset 'content'

回答
編輯回答
夏夕

你的返回值是json格式的數(shù)據(jù),轉(zhuǎn)化之后打印出來看下數(shù)據(jù)結(jié)構(gòu)就搞定了,不過最好做個判斷,防止數(shù)據(jù)為Null報錯~

2017年11月22日 05:53
編輯回答
扯機(jī)薄

返回的估計(jì)是字符串,使用json_decode處理下。

$info = json_decode($info, true);
2017年10月26日 16:14
編輯回答
孤巷

這是json格式的數(shù)據(jù) 你可以通過
json_decode($data,true);轉(zhuǎn)化為數(shù)組格式,這樣就可以用你寫的那種方式獲取獲取了

2017年2月4日 03:30
編輯回答
短嘆
error_log(var_export($info, TRUE));

不知道$info的結(jié)構(gòu),就把它打到log里看看咯。

2018年5月13日 08:01