PHP 5.3 - Troubleshooting 500 Errors - Debugging - Analysis Errors

Sometimes I will have some poorly formed PHP code and I will get a 500 error. I am running Apache 2.2 on a Windows 7 laptop. I started using PhpStorm as an IDE.

What is the best way to catch these errors and get line number information? Why do OOP-related syntax errors tend to throw 500 errors and problems with functions that tend to return normal errors?

Syntax error example: invoking a static method from a class with one colon instead of two colons.

UPDATE : See the accepted answer and all comments.

+6
source share
1 answer

PHP will answer “500” when it encounters a fatal error, such as E_PARSE , E_ERROR and fuzzy exceptions. 500 is the HTTP response code for "Internal Server Error" - something fatal happened while processing the request.

In your php.ini on the development machine, you should set the error_reporting level to (at least) E_NOTICE - preferably E_ALL - and make sure display_errors enabled. This will show you an error message in the browser, including for "500" errors.

You can also check your Apache error logs, errors will be indicated there if log_errors included in php.ini, By default it will be <apache_ServerRoot>\logs\error.log .

You can also manage all this at runtime ini_set() and error_reporting()

+12
source

Source: https://habr.com/ru/post/904095/


All Articles