Display php error at runtime

With the production server, we have to disable the error reporting. However, sometime we need to really see the error for debugging purpose. We can use this code to display the error at runtime:

<?php
error_reporting(E_ALL);
ini_set(“display_errors”, 1);

Or we can better debug with an if statement, for example

<?php
if($_GET[‘SECRET_PASSWORD’] == ‘SOME SECRET PASSWORD’) {
error_reporting(E_ALL);
ini_set(“display_errors”, 1);
}

we can use a secret password to display error like: http://myurl.com?SECRET_PASSWORD=xxx

or we can limit to only our IP address (recommend).

Advertisements