Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

* fix CVS tag

* improve PHPDoc comments
* ws


git-svn-id: http://svn.php.net/repository/pear/packages/Net_CheckIP/trunk@56004 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
commit a7f444802c52a238139a38db6acb87d7e7d80f32 1 parent 408c9f0
@mj mj authored
Showing with 11 additions and 11 deletions.
  1. +11 −11 CheckIP.php
View
22 CheckIP.php
@@ -17,18 +17,18 @@
// | Guido Haeger <gh-lists@ecora.de> |
// +----------------------------------------------------------------------+
//
-// $Id:
+// $Id$
/**
* Class to validate the syntax of IPv4 adresses
*
* Usage:
* <?php
-* require_once "Net_CheckIP/CheckIP.php";
+* require_once "Net_CheckIP/CheckIP.php";
*
-* if (Net_CheckIP::check_ip("your_ip_goes_here")) {
-* // Syntax of the IP is ok
-* }
+* if (Net_CheckIP::check_ip("your_ip_goes_here")) {
+* // Syntax of the IP is ok
+* }
* ?>
*
* @author Martin Jansen <mj@php.net>
@@ -49,23 +49,23 @@ class Net_CheckIP
* If all 4 parameters pass this test, the function
* returns true.
*
- * @param string IP adress
- * @return bool true if syntax is valid, otherwise false
+ * @param string $ip IP adress
+ * @return bool true if syntax is valid, otherwise false
*/
function check_ip($ip)
{
-
+
$count = 0;
-
+
$x = explode(".", $ip);
$max = count($x);
-
+
for ($i = 0; $i < $max; $i++) {
if ($x[$i] >= 0 && $x[$i] <= 255 && preg_match("/^\d{1,3}$/", $x[$i])) {
$count++;
}
}
-
+
if ($count == 4 && $max == 4) {
return true;
} else {
Please sign in to comment.
Something went wrong with that request. Please try again.