How can I get PHP to show the error instead of giving me a 500 Internal Server Error
P粉930534280
P粉930534280 2023-10-14 13:52:53
0
2
585

This has never happened before. Normally it would show an error, but now it just gives me a 500 Internal Server Error. Of course before, when it showed the error, it was a different server. Now I'm on a new server (I have full root so if I need to configure it somewhere in php.ini I can.) Or maybe it's an Apache thing?

I've been putting up with it and just transferring the files to my other server and running it there to find errors, but it's getting too tedious. Is there a way to solve this problem?

P粉930534280
P粉930534280

reply all (2)
P粉885562567

Usingphp -l(i.e. "L") from the command line outputs syntax errors that may cause PHP to throw a status 500 error. It will output the following:

PHP parsing error: Syntax error, unexpected "}" in line 18

    P粉738676186

    Check theerror_reporting,display_errorsanddisplay_startup_errorssettings in thephp.inifile. They should be set toE_ALLand"On"respectively (although you should not usedisplay_errorson a production server, so disable this option and use log_errors Instead, if/when you deploy it). You can also change these settings (exceptdisplay_startup_errors) at the beginning of the script so that they are set at runtime (although you may not catch all errors this way):

    error_reporting(E_ALL); ini_set('display_errors', 'On');

    After that, restart the server.

      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!