ThinkPHP5 报错The each() function is deprecated. This message will be suppressed on furthe

in PHP读书学习 with 0 comment

ThinkPHP5 报错The each() function is deprecated. This message will be suppressed on furthe

ThinkPHP5 报错The each() function is deprecated. This message will be suppressed on furthe

具体错误是这一句:

while (list($key, $val) = each($para)) {  }

原因是环境用PHP版本为7.2,PHP7.2废除了each()方法。解决方法也很简单,改为foreach即可。

foreach ($para as $key => $val) {  }