PHP Code: Prüft eine IP-Adresse

Prüft eine IP-Adresse auf ihre Korrektheit.

<?php

function ip($ip) {
 if (is_string($ip) && ereg('^([0-9]{1,3}).([0-9]{1,3}).([0-9]{1,3}).([0-9]{1,3})$',$ip, $part)) {
  if ($part[1] <= 255 && $part[2] <= 255 && $part[3] <= 255 && $part[4] <= 255) {
    return true;
  }
 }
  return false;
}

?>

Tags: , , ,

 
 
 

Hinterlasse eine Antwort