PHP 7 升级到Php8 ,worpress 出现的主题错误

-
0
rocky
7月 05, 2022 12:44 下午 1 回答 General
自 Apr 2022 以来的成员
Subscribed Subscribe Not subscribe
旗帜(0)

Warning: Attempt to read property "term_id" on string in /xxxxxx/wp-content/themes/milu/functions.php on line 637

Warning: Undefined array key 0 in /xxxxx/wp-content/themes/milu/functions.php on line 706

Warning: Attempt to read property "term_id" on null in /xxxxxx/wp-content/themes/milu/functions.php on line 707

 

出现未定义的键值

2 Subscribers
rocky
神经 少侠
Submit Answer
登录 进行回答。
1 Answers
排序:
最佳答案
0
神经 少侠
7月 06, 2022
旗帜(0)

Warning: Undefined array key

$cat = isset($cat[0]) ? $cat[0] : '';

php8 更严谨一些,需要判断一下变量赋值是否为空,可以用 isset() ? :  三元运算符来解决

 

 

登录来回复
回复为 提交