PHP报错:The each() function is deprecated. This message will be suppressed on further

PHP与SEO 思享 184浏览
摘要:
已弃用:each()函数已弃用。该消息将在第xxx行的/xxx/xxx.php中的进一步调用中被禁止

php7.2以上 废除了 each()方法,项目中用到的地方会出现以下报错

Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /xxx/xxx.php on line xxx

 解决办法

while (list($key, $val) = each($array)) {
#code
}

替换为

foreach ($array as $key => $val) {
#code
}

 

推荐阅读

PHP提示:Warning: count():Parameter must be an array or an object that implements Countable

错误原因:PHP7.2以后,count()函数的参数无效时会抛出warning警告。...

PHP7.4 报错:Deprecated Functionality: implode(): Passing glue string after array is deprecated.

PHP7.4运行项目报错:Deprecated Functionality: implode(): Passing glue string after array is deprecated。只需交换 implode() 函数的两个参数!...

百度自动推送php实现代码

我们知道主动推送有助于搜索引擎抓取和收录网站内容,wordpress或者主流CMS其实已经集成了推送功能。但是如果我们要定期归还,而不是只在发布的时候推一次。这个功能可以通过结合PHP和Pagoda Panel的预定任务来实现。$api = '百度站......