Turn error reporting ON xampp

2019-02-18 01:54发布

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

I used

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

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

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

3条回答
淡お忘
2楼-- · 2019-02-18 02:38

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 = On and/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.

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."

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.

Also I think you should make sure :

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

Or in PHP :

error_reporting(E_ALL & E_STRICT);
ini_set('display_errors', '1');
ini_set('log_errors', '0');
ini_set('error_log', './');
查看更多
干净又极端
3楼-- · 2019-02-18 02:46

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.

查看更多
走好不送
4楼-- · 2019-02-18 02:52

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 :).

查看更多
登录 后发表回答