P粉6045078672023-08-21 10:46:45
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 question may provide additional information.
P粉6914613012023-08-21 00:29:27
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 to php.ini
, putting this line in .htaccess
may also work):
php_flag display_errors 1
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. See Where to find the PHP error log
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.