php 打开错误报告 xampp

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12737048/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 04:07:22  来源:igfitidea点击:

Turn error reporting ON xampp

phperror-handlingxampperror-reporting

提问by FabianCook

So I have xampp and the thing won't report anything at all... I even forced an error and it didn't do anything...

所以我有 xampp 并且这个东西根本不会报告任何东西......我什至强迫一个错误并且它没有做任何事情......

I used

我用了

error_reporting(-1);
ini_set( 'display_errors', 1 );

according to this document http://php.net/manual/en/function.error-reporting.php

根据这个文件http://php.net/manual/en/function.error-reporting.php

also error_reporting(E_ALL);doesn't do anything either...

error_reporting(E_ALL);没有做任何事情......

回答by Bas van Ommen

Hey look at that, made a more insane error making code and it works... but why isn't it showing all errors?

嘿,看看那个,在编写代码时犯了一个更疯狂的错误并且它有效......但为什么它不显示所有错误?

Probably you're not getting any 'simple' errors like:

可能您没有收到任何“简单”错误,例如:

Parse error: syntax error, unexpected T_VARIABLE in .../.../index.php on line 6
#or
Warning: include(whateveryouwantedto.include): failed to open str(...)

But you do get things like:

但是你确实得到了这样的东西:

Fatal error: Call to undefined method stdClass::Crap() in .../.../index.php on line 6

According to my thinking hat, this is because if you don't disable logging in your PHP configuration the 'simple' errors will be sent 'nowhere'. In other words: PHP is 'helping' you by not showing any errors because you either defined log_errors = Onand/or error_log = 'php_errors.log'and it's logging all 'real' errors but your's just don't cut it to the 'real' category.

根据我的想法,这是因为如果您不禁用 PHP 配置中的日志记录,那么“简单”错误将“无处可发”。换句话说:PHP 通过不显示任何错误来“帮助”您,因为您定义log_errors = On和/或error_log = 'php_errors.log'记录了所有“真实”错误,但您的只是没有将其归入“真实”类别。

If this doesn't help, the thinking hat says: "It can't f* remember, but I sure as heaven/hell know it is somewhere in the PHP or Apache config."

如果这没有帮助,思维帽会说:“它不记得了,但我肯定知道它在 PHP 或 Apache 配置中的某个地方。”

Sure hope my thinking hat helped you out.

当然希望我的思考帽能帮助你。

EDIT: Tackling this problem might be to find and open php.ini, select all, delete/backspace, save (but keep open) (or save a copy somewhere). Then restart Apache. See if there's any difference. If so, the php configuration is somewhere else. Restore the php file and search your computer or server from the root up for another php.ini.

编辑:解决这个问题可能是找到并打开 php.ini,全选,删除/退格,保存(但保持打开)(或在某处保存副本)。然后重新启动Apache。看看有没有区别 如果是这样,则 php 配置在其他地方。恢复 php 文件并从根目录搜索您的计算机或服务器以查找另一个 php.ini。

Also I think you should make sure :

另外我认为你应该确保:

log_errors = Off
error_log = "./"
display_errors = On
error_reporting = E_ALL

Or in PHP :

或者在 PHP 中:

error_reporting(E_ALL & E_STRICT);
ini_set('display_errors', '1');
ini_set('log_errors', '0');
ini_set('error_log', './');

回答by Gary Owain Jones

In your folder xampp/php create new folder named logs. Go to control panel appache logs click php_error_log it will now ask if you want to create the file.

在您的文件夹 xampp/php 中创建名为 logs 的新文件夹。转到控制面板 appache 日志单击 php_error_log 它现在会询问您是否要创建文件。

回答by Gaming With Kman

error_reporting function is sometimes turned off on local servers, for example, Xampp does not support it so you have to go to php.ini and change it there. Hope this helps :).

error_reporting 功能有时在本地服务器上是关闭的,例如,Xampp 不支持它,所以你必须去 php.ini 并在那里更改它。希望这可以帮助 :)。