How to print PHP error in browsers

Default featured post

By default if your PHP code has some errors, it just shows white dead page which is so confusing and for me personally so annoying. By contrast of languages such as Java which you can easily check about any compile or runtime error, in PHP this task is not so straightforward.

In order to enable the print error in your PHP code for web browsers, you need to add the following two lines in the beginning of your code and preferably at top,

ini_set('display_errors', 1);

Bear in mind, after debugging your code, remove or comments the lines.