PHP won't show any errors

六眼飞鱼酱① 提交于 2019-12-02 01:34:37

问题


Here is my code:

echo 'foo';

error_reporting(E_ALL);

echo 'this line doesnt end in a semi colon'

echo 'i should get an error here';

When I run this I get no error.

Not sure how this can be?


回答1:


ini_set('display_errors', 1);

Do note though that if you do this in the file that has the syntax error, it won't work, as it'll never get executed then. You can also set this true in php.ini (not recommended for production servers), or if you use Apache, in .htaccess with:

php_flag display_errors 1



回答2:


error_reporting directive won't help you to show error messages on-screen. It's responsible for which error to show, not where.

if your PHP runs as Apache module (most likely it does) add the following line into .htaccess file:

php_value display_errors 1

when you switch to production, change it to

php_value display_errors 0
php_value log_errors 1

and watch them it in the error log.




回答3:


Do you have any kind of shutdown hooks, error-handling functions or global exception catchers running?

Syntax errors can be quirky in large frameworks :)



来源:https://stackoverflow.com/questions/3831151/php-wont-show-any-errors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!