简体   繁体   English

如何在Ubuntu 16.04上的PHP 7中显示错误?

[英]How to display errors in PHP 7 on Ubuntu 16.04?

I've set in my php.ini file the values: 我在php.ini文件中设置了值:

display_errors  On
display_startup_errors  On

And in my laravel application: 在我的laravel应用程序中:

 'debug' => env('APP_DEBUG', true),

But when i purpose write some gibberish in my controller method the page gets blank instead of displaying an error. 但是,当我打算在控制器方法中写一些乱码时,页面将变为空白而不是显示错误。 What else is suppressing this to show an error message? 还有什么抑制它显示错误消息的呢?

转到/etc/php/7.0/apache2位置,并在驻留在此处的php.ini中启用错误。别忘了重新启动apache2

Was xdebug.force_display_errors=Off in php.ini. 在php.ini中是否为xdebug.force_display_errors = Off。 It overrides the other settings obviously. 它显然会覆盖其他设置。

Add ini_set('display_errors', 1); 添加ini_set('display_errors',1); on top of the code. 在代码之上。 Once you finish debugging, you can remove it. 完成调试后,可以将其删除。 Also you can set these up based on environment variables. 您也可以根据环境变量进行设置。 For example you can set constant DEVELOPMENT to true only in development environment and use following code to enable error reporting 例如,您可以仅在开发环境中将常量DEVELOPMENT设置为true,并使用以下代码启用错误报告

if (defined('DEVELOPMENT') && DEVELOPMENT === true)
{
    ini_set('display_errors', 1);
    error_reporting(E_ALL);
    ini_set("display_errors", 1);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM