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

如何在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?

  • 写回答

4条回答 默认 最新

  • 普通网友 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");
    
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥20 关于TRPD(波形特征)局部放电特征提取
  • ¥15 C语言快速排序函数纠错
  • ¥15 C#的一个应用程序书写
  • ¥65 页面调接口时加载卡住不响应
  • ¥35 用C语言解决编程问题
  • ¥15 unity硬件连接与使用
  • ¥15 鱼缸加热棒的数据分析或者实际案例也行
  • ¥15 postgresql11安装完成后,pgadmin无法启动
  • ¥15 (标签-无人机|关键词-Matlab代码)
  • ¥15 执行shell脚本提示参数太多