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

-
0
rocky
7月 05, 2022 12:44 下午 1 Answers General
Member Since Apr 2022
Subscribed Subscribe Not subscribe
Flag(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
Submit Answer
Please login to submit answer.
1 Answers
Sort By:
Best Answer
0
神经 少侠
7月 06, 2022
Flag(0)

Warning: Undefined array key

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

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

 

 

Sign in to Reply
Replying as Submit