douliedai4838
2016-06-28 11:32
浏览 185
已采纳

如何在yii2中隐藏php警告?

My yii2 web application is hosted on shared server.

it is showing php warning - " PHP Core Warning – yii\base\ErrorException PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20100525/imagick.so' - libMagickWand.so.2:

cannot open shared object file: No such file or directory" now i want to disable php warning in my yii2 application how to achive that?

图片转代码服务由CSDN问答提供 功能建议

我的yii2 Web应用程序托管在共享服务器上。

显示php警告 - “PHP核心警告 - yii \ base \ ErrorException 启动:无法加载动态库'/ usr / local / lib / php / extensions / no-debug-non-zts-20100525 / imagick.so' - libMagickWand.so.2:

无法打开共享对象文件:没有这样的文件或目录“ now我想在我的 yii2 应用程序中禁用php警告如何实现?

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

4条回答 默认 最新

  • duanlv4984 2017-11-17 11:05
    已采纳

    This can be achieved by changing two parameters in index.php file.

    1) Setting YII_DEBUG to false

    defined('YII_DEBUG') or define('YII_DEBUG', false);
    

    2) Setting YII_ENV to prod from dev

    defined('YII_ENV') or define('YII_ENV', 'prod');
    
    已采纳该答案
    打赏 评论
  • dougou7782 2016-06-28 11:38

    Update public/index.php

    error_reporting(E_ERROR);
    

    When working on your script, i would advise you to properly debug your script so that all notice or warning disappear one by one. So you should first fix that warning message.

    打赏 评论
  • dongqi8030 2016-06-28 11:38

    Comment the following 2 lines in your entry script (index.php)

    defined('YII_DEBUG') or define('YII_DEBUG', true);
    defined('YII_ENV') or define('YII_ENV', 'dev');
    

    Further, you can also disable the warnings at PHP level by setting error_reporting to appropriate value as per the documentation - http://php.net/manual/en/errorfunc.configuration.php#ini.error-reporting

    打赏 评论
  • dtl4521 2016-06-28 11:40

    Use below code to check all error notice and warning.

     error_reporting(E_ALL);
     ini_set("display_startup_errors","1");
     ini_set("display_errors","1");
    
    打赏 评论