How to avoid see errors on screen

Hi guys,
in my php.ini of webserver, I placed following order:
display_errors = Off

Following oder
grep display_errors ./php5/fpm/php.ini will show

;display_errors
display_errors = Off
display_errors = Off

Anyway, I will see errors on screen. How to avoid this unwanted behaviour?

Hi,
Can you please explain bit more , which kind of errors you wanted to hide.

The best way to comment out two line of dev environment in entry script (index.php)

// comment out the following two lines when deployed to production
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');

or add this line at top of index.php

error_reporting(0)

Let me know please.

Thank You

I have following code in frontend/web/index.php

<?php

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

require __DIR__ . '/../../vendor/autoload.php';
require __DIR__ . '/../../vendor/yiisoft/yii2/Yii.php';
require __DIR__ . '/../../common/config/bootstrap.php';
require __DIR__ . '/../config/bootstrap.php';

$config = yii\helpers\ArrayHelper::merge(
                require __DIR__ . '/../../common/config/main.php', require __DIR__ . '/../../common/config/main-local.php', require __DIR__ . '/../config/main.php', require __DIR__ . '/../config/main-local.php'
);

(new yii\web\Application($config))->run();
?>

So, U suggest me to delete following lines,correct?

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

What is sense of defined('YII_ENV') or define('YII_ENV', 'dev'); . What is this php staement doing?

if (!defined(‘YII_ENV’))
define(‘YII_ENV’, ‘dev’);

these statement are just for debugging purpose, if YII_ENV is dev then it will show all kind of errors and warning at browser window.
If you comment these two lines that mean the app is ready for production that mean YII_ENV is prod , so it will stop showing any error or warning except any php FATAL error.

Let me know if you got my point.
Thank You

Year. Absolutely corrrect. But, I only deleted following line:

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

From now on, user will see content of site/error.php, which is absolutely, what he should see. Thx a lot for ur efforts, helping me!

Hi,
If you remove
defined('YII_ENV') or define('YII_ENV', 'dev');
still user can see errors, those are obvious , like:
404, 403
and if there is any error that related to syntax or database exception then user can not see that instead of original error they can see only this
500 , internal server error

or if you don’t want to remove then you can replace dev to prod and then application is ready for end users.

I hope this will also help you in further development.

Thank You