note 39028 added to function.ereg

From: Date: Thu, 15 Jan 2004 00:54:06 +0000
Subject: note 39028 added to function.ereg
Groups: php.notes 
Request: Send a blank email to php-notes+get-63574@lists.php.net to get a copy of this message
Here is an optional IP-Validator-Scipt !without! the ereg-function ... may be faster - don't know =) //---------------------------------------- $ip = "123.123.123.123"; /* or $ip = $REMOTE_ADDR; */ function iptest ($ip) { $ip = explode (".",$ip); if (count($ip) != 4) { return FALSE; } for ($i = 0; $i <= 3; $i++) { if ($ip[$i] <= 255 && $ip[$i] >= 0) { $P++; } } if ($P == 4) { return TRUE; } else { return FALSE; } } if (iptest($ip)) { echo "IP address is correct"; } else { freak_out(); } //---------------------------------------- hope it helps =) ---- Manual Page -- http://www.php.net/manual/en/function.ereg.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+39028 Delete -- http://master.php.net/manage/user-notes.php?action=delete+39028&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+39028&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#63574) next »