PHP - error_reporting doesn't work

2020-03-27 10:46发布

My webhosting provider doesn't offer the option to enable error reporting. So tried it with error_reporting(E_ALL); But this also doesn't work. I tried the following script:

 <?php
 error_reporting(E_ALL);
 echo $test;
 ?>

If I read the manual correctly, then this should generate an error notice. But this also doesn't work. Did I make something wrong or is the only solution to get a new webhosting provider?

标签: php
4条回答
祖国的老花朵
2楼-- · 2020-03-27 11:05

If its a shared hosting then for security reasons, they may disable error reporting, still they should be able to provide error log for your particular domain, try talking to them if they don't want to show it inline - get access go log file or maybe some adminpanel that can read it securely.

查看更多
ら.Afraid
3楼-- · 2020-03-27 11:16

You probably want to do something with the triggered error, such as logging it:

ini_set('error_log', '/path/to/php-error.log');

... and/or displaying it:

ini_set('display_errors', TRUE);

Please find additional documentation at Error Handling and Runtime Configuration.

查看更多
▲ chillily
4楼-- · 2020-03-27 11:16

You also need:

ini_set('display_errors', true);
查看更多
Anthone
5楼-- · 2020-03-27 11:29

error_reporting is just telling PHP how verbose the error reporting should be, but you also need to tell it to actually display errors out to the browser by setting

ini_set('display_errors', 1);
查看更多
登录 后发表回答