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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: