#native_company# #native_desc#

Beginner Debugging: For Your Eyes Only Page 3

By John Starkey
on October 30, 2002

Checking For Safe Debugging

In my prepend file, or at the top of an example file, I add the following lines of code.


/* start with debugging off */

$debug 0;

/* an array containing a list of IPs that may view your data. */

$debug_ips = array('');

/* make sure debugging is off to avoid it being set in the url */

$debug_ok 0;

/* determine if it's ok to throw errors to the screen */

if ( $debug == && in_array$_SERVER['REMOTE_ADDR'], $debug_ips ) )

$debug_ok 1;


The above snippet verifies that it’s ok to send debugging information to the browser. We have two basic
requirements: the IP is in the $debug_ips array and debug is turned on (that is: $debug is set to ‘1’).
By setting this early on and using a single variable, $debug_ok, throughout the site we can change the
requirements at any time and not have to edit anything other than this data.
If you’d like to add someone to your list of people allowed to see the data, just add their IP to the
$debug_ips array.