PHPBuilder - Beginner Debugging: For Your Eyes Only Page 3



RSS Twitter
Articles Tricks And Hacks

Beginner Debugging: For Your Eyes Only - Page 3

by: John Starkey
|
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.

<?php

/* start with debugging off */
$debug 0;

/* an array containing a list of IPs that may view your data. */
$debug_ips = array('192.168.0.2');

/* 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.

« Previous Page
1
|
2
|
3
|
4
|
5
Next Page »

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
John Starkey

Comment:



Comment:

(Maximum characters: 1200). You have characters left.