note 32498 rejected from function.getenv by danbrown

From: Date: Sun, 20 Jul 2008 00:21:21 +0000
Subject: note 32498 rejected from function.getenv by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-141838@lists.php.net to get a copy of this message
Note Submitter: Joenema at aol dot com ---- This is just a reply to Anders Winther's fool-proof IP address fetcher. What he has is good, but uses a lot of superfluous lines. Basically, he could have done this: function getIP() { $ip; if (getenv("HTTP_CLIENT_IP")) $ip = getenv("HTTP_CLIENT_IP"); else if(getenv("HTTP_X_FORWARDED_FOR")) $ip = getenv("HTTP_X_FORWARDED_FOR"); else if(getenv("REMOTE_ADDR")) $ip = getenv("REMOTE_ADDR"); else $ip = "UNKNOWN"; return $ip; } Do you see how those numerous lines of code compressed into a few lines?

« previous php.notes (#141838) next »