By default, displaying errors is turned off because you don't want a "customer" seeing the error messages.
Check this page in the PHP documentation for information on the 2 directives: error_reporting
and display_errors
. display_errors
is probably the one you want to change.
So you have 3 options:
(1) You can check the error log file as it will have all of the errors (unless logging has been disabled). To enable error logging make sure that log_errors
configuration directive is set to On
. Logs are also helpful when error is happened not in PHP but emitted by web-server.
(2) You can add the following 2 lines that will help you debug errors that are not syntax errors happened in the same file:
error_reporting(E_ALL);
ini_set('display_errors', 'On');
Note that on a live server the latter should be set to Off
(but only the latter, because you still need to learn about all errors happened, from the log file).
However, for syntax errors happened in the same file, the above commands won't work and you need to enable them in the php.ini. If you can't modify the php.ini, you may also try to add the following lines to an .htaccess file, though it's seldom supported nowadays:
php_flag display_errors on
php_value error_reporting -1
(3) Another option is to use an editor that checks for errors when you type, such as PhpEd, VSCode or PHPStorm. They all come with a debugger which can provide more detailed information. (The PhpEd debugger is very similar to xdebug and integrates directly into the editor so you use 1 program to do everything.)