tags:

views:

48

answers:

4

I am making some changes on the live site and i constantly need to add loggers (print_r) throughout the page for me to test. The problem is the site is healily populated by staff and I need it so I am for sure the only one to see this logger. I heard I can wrap the logger in an if with my Ip address but i thought I while back i tried that and the client still viewed it. Anybody have an ideas or the syntax needed to make this happen. By the way I think the PHP version is an older on

+5  A: 

You could always pass yourself a variable in get and switch on that

http://mysite.com?debug=secret

then:

  if($_GET['debug'] === "secret"){
     print_r($stuff);
  }

Before I used frameworks I used to set a cookie when debug="secret" so that I do not have to put it all the time. And since only you have the cookie set you are ok.

Iznogood
+1  A: 

This restricts //your debug code to IP 12.34.56.78.

if(isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] == '12.34.56.78'){
   //your debug code
}

You could also store this in a constant:

define('SHOWDEBUG', isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] == '12.34.56.78');

Somewhere else: SHOWDEBUG && print_r($dumped);

Lekensteyn
A: 

Make a page that lets you set or clear a "debug" cookie. Make sure you put a password on that page so the client can't mess with it.

Ian
A: 

agreed with lznogood.

i would add some secret
<?php
$a=$_GET[];
if($a=xyz){
}
?>
note: it wouldn't hurt to make the get some encrypted value equal to some other large encrypted value. then just bookmark this for yourself and set it in the code.

i have this active on my page for layout//connection reasons.

jason m