Revision: 34700
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 27, 2010 07:44 by dmertl
Initial Code
function isValidDomain($value) { if($value) { //Max 255 chars if(strlen($value) > 255) { return false; } //Remove trailing . if(substr($value,-1,1) == '.') { $value = substr($value,0,-1); } $labels = explode('.',$value); //More than 2 labels if(count($labels) >= 2) { foreach($labels as $label) { //Cannot start or end with a - if(substr($label,0,1) == '-' || substr($label,-1,1) == '-') { return false; } //Allowed characters a-z, 0-9, - if(!preg_match('/^[a-z\d-]{1,63}$/i',$label)) { return false; } } } else { return false; } return true; } return false; }
Initial URL
Initial Description
Initial Title
PHP - Valid DNS name
Initial Tags
php
Initial Language
PHP