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

PHP与SEO 思享 591浏览
摘要:
已弃用: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
}

 

推荐阅读

Function get_magic_quotes_gpc() is deprecated报错解决办法

在 PHP 7.4 及更高版本中, get_magic_quotes_gpc() 函数已被弃用。 This means that code using this function will raise a warning or error.以下是解决......

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() 函数的两个参数!...