php - 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?
解决方案
正如其他人已经评论的那样,代码不会按预期工作(使用按位运算符)。试试in_array()
吧。
in_array(Config::LOG_LEVEL, ['debug', 'basic', 'light'])
推荐阅读
- c# - 从 sqlite 返回的 C# 序列化 DataTable 结果正在返回 XML 格式
- android-studio - 当我启动 android 应用程序时,我可以在 logcat 中看到警告并终止应用程序
- c++ - 可以在基于范围的 for 循环中使用模板化的开始/结束方法吗
- sql-server - 为什么我的 SQL Server 差异备份有时会失败?
- google-apps-script - 应用程序在提醒类型的日历中添加事件
- mysql - MySQL:如果存在则选择最新记录,如果不存在则为 NULL
- gstreamer - GStreamer 插件 'interpipe' (Ridgerun) 和 intervideo 不处理 RGB 格式
- javascript - 如何动态更改函数的名称
- python - 分析给我的数据集,只有特征,没有问题陈述
- c - 为什么在违反运行时约束的情况下 memcpy_s 会归零?