note 105566 modified in function.gethostbyaddr by danbrown

From: Date: Mon, 29 Aug 2011 12:47:25 +0000
Subject: note 105566 modified in function.gethostbyaddr by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-182806@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('..') <?php $IP = "BadValue.123.123.123"; if(intval($IP)>0){ $ServerIP = gethostbyaddr($IP); } else { $ServerIP = $IP; // A bad address. } ?> --was-- 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. } http://php.net/manual/en/function.gethostbyaddr.php

« previous php.notes (#182806) next »