How to solve PHP error display problems
P粉469090753
P粉469090753 2023-08-20 11:45:59
0
2
528

I have checked my PHP ini file (php.ini) and display_errors is set and error reporting is also E_ALL. I have restarted my Apache web server.

I even put these lines at the top of my script, but it doesn't even catch simple parsing errors. For example, I declare a variable with "$", but I don't have the closing statement ";". But all the scripts display a blank page on these errors, but I would like to actually see errors in the browser output.

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

Is there anything else that needs to be done?

P粉469090753
P粉469090753

reply all (2)
P粉604507867

You can't catch parse errors in the same file with runtime error output enabled, because it parses the file before actually executing anything (and since it encounters errors along the way, it won't execute anything). You need to change the actual server configuration so that display_errors is turned on and the appropriate error_reporting level is used. If you don't have access to php.ini, you might be able to use .htaccess or similar, depending on the server.

This questionmay provide additional information.

    P粉691461301

    Development environment

    This always works for me:

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

    However, this does not make PHP show parsing errors that occur in the same file - the only way to show these errors is to modify your php.ini file to add this line:

    display_errors = on

    (If you don't have access tophp.ini, putting this line in.htaccessmay also work):

    php_flag display_errors 1

    Production Environment

    Please note that the above suggestions only apply to development environments. In a production environment this must be set to:

    display_errors = off log_errors = on

    Then you can see all the errors in the error log. SeeWhere to find the PHP error log

    AJAX call

    For AJAX calls, open DevTools (F12) on the development server and select the Network tab. Then make the request you want to see the results of and it will appear in the Network tab. Click on it and select the Response tab. There you will see the exact output.
    On the production server, just check the error log.

      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!