Search code examples
phpdebugginggoogle-chromeerror-handlingerror-reporting

Can't enable error reporting in PHP within Chrome


I'm testing PHP on a LAMP server running in a Linux virtual machine. Following this post, I placed the following at the beginning of my PHP script to enable error reporting:

ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);

I also tried enabling error reporting in the php.ini file as described here:

display_errors = On
display_startup_errors = On
error_reporting = -1

However, I still get a 500 Internal Server Error in Chrome's debugger, rather than a proper error message:

enter image description here

The actual error message, as found in /var/log/apache2/error.log, is:

PHP Parse error: syntax error, unexpected '$userID' (T_VARIABLE) in /path/to/file

How can I properly enable error reporting within Chrome?


Solution

  • That is Apache (server) response and (probably) has nothing to do with php.
    It simply states that there is something wrong with your server configuration. Check the access.log and error.log in /var/log/apache2/ folder. It is probably due to wrong configuration in /etc/apache2/apache2.conf, or in /var/www/.htaccess (if you have one).

    I would also check if list.php exists in webroot folder and if both folder and file are readable (use chmod -R 755 /var/www in cli to make all files and folders readable)