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
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.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With