I often am asked to make tweaks to a live site which is risky for numerous reasons. Foremost, if I haven't had enough coffee, I might make a simple typo, casuing a big fat glorious error for everyone to see. Secondly, it's often neccesary to print out arrays, or variables to see their values.. sometimes these variables contain sensitive info that you don't want anyone else to see.
Here is a simple way to print out info for a particular IP address ..
| Code: |
if ($_SERVER['REMOTE_ADDR'] == "123.123.123"){
echo "<hr><pre><textarea>" . $some_variable ."</textarea></pre></hr>";
}
|
or for an array, use the print_r function with the true flag..
| Code: |
if ($_SERVER['REMOTE_ADDR'] == "123.123.123"){
echo "<hr><pre><textarea>" . print_r($some_variable, true) ."</textarea></pre></hr>";
}
|
Obviously you'll need to determine your own IP address, and use an existing variable or array name.