有没有CodeIgniter投掷500s替代?
I'm trying to learn CodeIgniter, and I'm constantly running into "500, Internal Server Error". So far, I've learned that that usually means I have a typo somewhere, but it still is kind of hard to find the typo because it doesn't tell you where it is.
Is there a way that I can tell CodeIgniter to tell me what's wrong rather than making Apache throw a "500, Internal Server Error"? I'm an intermediate PHP programmer, and I've thrown more 500 errors in the past two days with CodeIgniter than I have since I started coding PHP! Can I get CodeIgniter to tell me the syntax errors rather than having Apache give me 500s?
我正在尝试学习CodeIgniter,而且我经常遇到“500,内部服务器错误”。 到目前为止,我已经了解到这通常意味着我在某个地方有一个拼写错误,但是仍然很难找到拼写错误,因为它没有告诉你它在哪里。 p>
有没有办法告诉CodeIgniter告诉我什么是错误而不是让Apache抛出“500,内部服务器错误”? 我是一名中级PHP程序员,在过去的两天里,我使用CodeIgniter抛出了500多个错误,因为我开始编写PHP代码! 我可以让CodeIgniter告诉我语法错误,而不是让Apache给我500秒吗? p> div>
I wish I could give credit to Lawrence Cherone, because his comment really helped me solve my problem.
I started looking in the access and error logs and started finding what my errors were quite quickly. When I ran into those 500 errors, it solved my problems by looking at the apache2 logs.
It seems like these errors are caused by the CI function show_error($message, $status=500)
. CI itself has a custom 500 error page, which does include any php errors that caused the 500 response (assuming of course your error reporting is turned on in php.ini and the CI ENVIRONMENT
constant is not set to 'production'
).
If you are getting a generic 500 error page, it would seem that some setting in Apache is overriding the custom page sent by CI. As @safarov suggested try checking you Apache config or .htaccess files for an explicit 500 error response.