Here’s a quick little function which can be used to return your IP address

  1. function getRemoteIPAddress() {
  2.         $ip = $_SERVER[‘REMOTE_ADDR’];
  3.         return $ip;
  4. }

The result can be very handy when combined with an if statement to code parts of a site you don’t want the end user to see. Just remember you need to know your IP address before you can create the statement below.

  1. $ip = getRemoteIPAddress();
  2.  
  3. if($ip == "insert your IP here") {
  4.         //run the code only you want to see here
  5. }