Most servers are set to suppress PHP errors which can leave you guessing why something isn't working and make troubleshooting code almost impossible. This is especially frustrating when you install a 3rd party module with errors. Luckily forcing PHP to display errors is very easy.
The most basic way to accomplish this is to just add the following 2 lines to the top of your PHP code.
Copy this code…
You can just individually place this code in each page your debugging OR if you're using a system such as drupal or wordpress you can just add this to the top of your settings file as it is included in every page of the site so it will make all the pages show errors. This is very useful for development just remember to remove it before taking the site live
Alternative for live sites – making PHP save errors to a log file
Obviously this is a reason why the PHP errors don't show. So before taking a site live you should disable them again. However, If errors do happen you might want a simple way to be able to see whats going on without letting the whole world see that your page is throwing errors.
Again the solution is simple. Just put the following code in you .htaccess file. Just be sure to update the path listed for your error file to reflect the actual location you want the error file to store. Also make sure that the server has write permissions to the file.
php_flag log_errors on php_value error_log /home/path/public_html/domain/PHP_errors.log