首页 > 解决方案 > PHP7.2 A non-numeric value encountered

问题描述

the following part of my code worked fine under PHP7.0:

if (Config::LOG_LEVEL == 'debug' | 'basic' | 'light') {}

I have now updated to PHP7.2 and the following error message appears:

A non-numeric value encountered

does anyone have any idea how i can fix this bug?

标签: phpphp-7.2

解决方案


正如其他人已经评论的那样,代码不会按预期工作(使用按位运算符)。试试in_array()吧。

in_array(Config::LOG_LEVEL, ['debug', 'basic', 'light'])

https://3v4l.org/ScWH5


推荐阅读