note 105566 added to function.gethostbyaddr
| From: | MarkinSussex at osu1 dot php dot net | Date: | Sun, 28 Aug 2011 18:21:44 +0000 |
| Subject: | note 105566 added to function.gethostbyaddr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-182790@lists.php.net to get a copy of this message | ||
If you use gethostbyaddr() with a bad IP address then it will send an error message to the error
log.
If you don't want your error log file getting too big then first check that the IP address is
valid.
In the following example I first check if the IP number starts with a number,
if not then don't use gethostbyaddr('..')
$IP = "BadValue.123.123.123";
if(intval($IP)>0){
$ServerIP = gethostbyaddr($IP);
} else {
$ServerIP = $IP; // A bad address.
}
----
Server IP: 87.124.126.127
Probable Submitter: 90.195.232.64 (proxied: 90.195.232.64)
----
Manual Page -- http://www.php.net/manual/en/function.gethostbyaddr.php
Edit -- https://master.php.net/note/edit/105566
Del: integrated -- https://master.php.net/note/delete/105566/integrated
Del: useless -- https://master.php.net/note/delete/105566/useless
Del: bad code -- https://master.php.net/note/delete/105566/bad+code
Del: spam -- https://master.php.net/note/delete/105566/spam
Del: non-english -- https://master.php.net/note/delete/105566/non-english
Del: in docs -- https://master.php.net/note/delete/105566/in+docs
Del: other reasons-- https://master.php.net/note/delete/105566
Reject -- https://master.php.net/note/reject/105566
Search -- https://master.php.net/manage/user-notes.php