是否可以阻止记录特定类型的 PHP 警告?我不想完全禁用警告,我只想禁用以下错误记录:
[Wed May 12 11:20:17.630952 2021] [:error] [pid 25301] [client 127.0.0.1:57710] PHP Warning: mysqli::mysqli(): (28000/1045): Access denied for user 'apache'@'localhost' (using password: NO) in /www/public_html/example.com/myphpfile.php on line 11, referer: https://example.com/anotherfile.php
同时保留如下警告:
[Wed May 12 11:23:21.355798 2021] [:error] [pid 21467] [client 127.0.0.1:49508] PHP Warning: Illegal string offset 'someindex' in /www/public_html/example.com/index.php on line 296, referer: https://example.com/somescript.php?param=1234
我的error_reporting
线路/etc/php.ini
如下所示:
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE
答案1
修复 PHP 文件或脚本配置中的问题。您应该将每个警告视为可能的错误,并且您希望尽可能保持系统不受错误的影响。