Occasionally I will have some badly formed PHP code and I will get a 500 error. I’m running Apache 2.2 on a Windows 7 laptop. As an IDE I have started using PhpStorm.
What is the best way to catch these errors and be informed of the line number?
Why do the OOP-related syntax errors tend to throw 500 errors and function problems tend to return normal errors?
Example of syntax mistake: calling a static method from a class with a single colon instead of two colons.
UPDATE:
Please see accepted answer and all comments.
PHP will respond with a “500” when it encounters a Fatal error, such as
E_PARSE,E_ERRORand uncaught exceptions. 500 is the HTTP response code for “Internal Server Error” – something unrecoverable happened while processing the request.In your php.ini, on a development machine, you should set your
error_reportinglevel to (at least)E_NOTICE– preferablyE_ALL– and make suredisplay_errorsis on. This will show you the error message in the browser, including for “500” errors.You can also check your Apache error logs, the errors will be listed there, as long as
log_errorsis enabled in php.ini. By default, this will be at<apache_ServerRoot>\logs\error.log.You can also control all this at run time with
ini_set()anderror_reporting()