dongshuzui0335 2018-04-18 08:11
浏览 63
已采纳

在WordPress页面中禁止PHP警告和通知

When I try to load WordPress, I get a lot of Use of undefined constant ‘view’ - assumed '‘view’' type of warnings and notices in the browser. This causes the pages to fill up with these messages before it renders the actual page content expected.

I tried changing error_reporting = E_ALL to error_reporting = E_ALL & ~E_NOTICE & ~E_WARNING but the warnings and notices still show up.

After doing php --ini I located both the 7.0 and 7.1 ini files and updated the value in both and restarted both FPM services on my vagrant.

  • /etc/php/7.0/fpm/php.ini
  • /etc/php/7.1/fpm/php.ini

Why are these still showing up?

  • 写回答

2条回答 默认 最新

  • doushi9444 2018-04-18 08:19
    关注

    You can combine WordPress build-in constants and PHP's ini settings.

    Place these lines in your wp-config.php

    ini_set('log_errors','on');
    ini_set('display_errors','off');
    ini_set('error_reporting', E_ALL );
    
    define('WP_DEBUG', false);
    define('WP_DEBUG_LOG', true);
    define('WP_DEBUG_DISPLAY', false);
    

    This way all notices, warnings and errors will not be shown on the front-end of your website, but errors are still accesable by a log file.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 只改动本课件的 cal_portfolio_weight_series(decision_date), 跑完本课件。设计一个信息比率尽量高的策略。
  • ¥20 如何在visual studio 2022中添加ImageMagick库
  • ¥50 如何实现uniapp编译的微信小程序做可回溯视频
  • ¥15 求Houdini使用行家,付费。价格面议。
  • ¥15 前端高拍仪调用问题报错
  • ¥15 想用octave解决这个数学问题
  • ¥15 Centos新建的临时ip无法上网,如何解决?
  • ¥15 海康威视如何实现客户端软件对设备语音请求的处理。
  • ¥15 支付宝h5参数如何实现跳转
  • ¥15 MATLAB代码补全插值