The each() function is deprecated. This message will be suppressed on furthe原因与解决方法

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

The each() function is deprecated. This message will be suppressed on further calls

中文翻译

each()函数已弃用。此消息将在以后的呼叫中被禁止

 

解决方法

解决方法其实也很简单,只需要将:

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

改为

foreach ($array as $key => $val) {
#code
}
    A+
发布日期:2019年11月24日 22:32:00  所属分类:PHP
最后更新时间:2020-04-09 19:36:25
头像
  • ¥ 398.0元
  • 市场价:598.0元
  • ¥ 98.0元
  • 市场价:398.0元
  • ¥ 189.0元
  • 市场价:269.0元
  • ¥ 98.0元
  • 市场价:298.0元

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

目前评论:2   其中:访客  0   博主  0

  1. 头像 youlingdada 0

    二个不一样的东西,在php5.6中,while配合each、list与foreach是两个不同的遍历数组方法好不,现在你叫我把一个改成另一个,不是在逃避这个问题吗

    • 付杰 付杰

      @youlingdada 你可以自己研究一个好的方法,有的话,可以分享出来。