P粉2036487422023-08-24 09:52:04
You can't catch parse errors in the same file with error output enabled at runtime, because it parses the file before actually executing anything (and since it encounters errors in the meantime, it doesn'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 a .htaccess or similar file, depending on the server.
This question may provide more information.
P粉4652875922023-08-24 09:23:23
This always works for me:
ini_set('display_errors', '1'); ini_set('display_startup_errors', '1'); error_reporting(E_ALL);
However, this will not make PHP show parsing errors that occur in the same file - the only way to show these errors is to modify php.ini with the following 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. On the actual website it must be
display_errors = off log_errors = on
Then you will be able to see all errors in the error log. SeeWhere to find the PHP error log
If it is an AJAX call, open DevTools (F12) on the development server and open the Network tab.
Then make a request for the results you want to see and it will appear in the Network tab. Click it and then click the Response tab. There you will see the exact output.
While on the live server, just check the error logs.