求一个验证ipv4,ipv6,FQDN的方法 就是验证一个输入,既可以是ipv4,也可以是ipv6,还可以是合法的域名谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //-------------------->IP地址验证-------------------- function i_ip(){ if(!ereg("^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$", $this->var_value)){ $this->array_errors[$this->var_key]="错误的IP地址"; }else{ //每个不大于255 $array_temp=preg_split("/\./",$this->var_value); foreach($array_temp as $ip_value){ if((int)$ip_value >255) $this->array_errors[$this->var_key]="错误的IP地址"; } } return true; } //-------------------->域名验证-------------------- function i_domain() { if(!eregi("^@([0-9a-z\-_]+\.)+[0-9a-z\-_]+$", $this->var_value)) $this->array_errors[$this->var_key]="错误的域名"; return eregi("^@([0-9a-z\-_]+\.)+[0-9a-z\-_]+$", $this->var_value); } //-------------------->URL验证-------------------- function i_url(){ if(!eregi('^(http://|https://){1}[a-z0-9]+(\.[a-z0-9]+)+$' , $this->var_value)) $this->array_errors[$this->var_key]="错误的WEB地址"; return true; } 用JAVA做的一个项目如何用.bat的文件启动 关于动态数组类型 关于读文件然后写入数据库的效率问题 core java 2 中是不是出错了? Thread sleep 使用问题。 中兴面试题之一 关于resultset的问题? 构造函数的问题??? ???(初学者问题)高手高手高高手快进,在先等 送份题,请问那里有JAVA核心类库详解下载 ButtonGroup 如何以编程方式“关闭” 一个根据数据库的值自动返回单选复选框是否被选中的问题
function i_ip(){
if(!ereg("^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$", $this->var_value)){
$this->array_errors[$this->var_key]="错误的IP地址";
}else{
//每个不大于255
$array_temp=preg_split("/\./",$this->var_value);
foreach($array_temp as $ip_value){
if((int)$ip_value >255)
$this->array_errors[$this->var_key]="错误的IP地址";
}
}
return true;
}
function i_domain() {
if(!eregi("^@([0-9a-z\-_]+\.)+[0-9a-z\-_]+$", $this->var_value))
$this->array_errors[$this->var_key]="错误的域名";
return eregi("^@([0-9a-z\-_]+\.)+[0-9a-z\-_]+$", $this->var_value);
}
function i_url(){
if(!eregi('^(http://|https://){1}[a-z0-9]+(\.[a-z0-9]+)+$' , $this->var_value))
$this->array_errors[$this->var_key]="错误的WEB地址";
return true;
}