Warning: Illegal string offset 'account' in 解決方法


比如這段代碼:

if ( (!empty($_GPC['uniacid_source']) && $_GPC['uniacid_source'] == 'wxapp') ) {
$uniacid = intval($_GPC['uniacid']);
if (!empty($uniacid)) {
isetcookie('__uniacid', $uniacid, 7 * 86400);
$cache_lastaccount['account'] = $uniacid;
cache_write($cache_key, $cache_lastaccount);
}
} else {
$uniacid = $cache_lastaccount['account'];
}
報錯的原因是
$cache_lastaccount數組里面有空數組,空數組里沒有account這個字段。最終解決辦法是:
只需要把紅色的部分修改成:$uniacid = isset($cache_lastaccount['account']) ?$cache_lastaccount['account'] : '';
還有一個報錯的原因是數據庫儲存的內容不正確,可以刪除該字段。
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM