繁体中文
设为首页
加入收藏
当前位置:PHP技术首页 >> PHP应用 >> 怎样校验输入的日期为合法的日期?这里有一个例子(checkdate.php3)

怎样校验输入的日期为合法的日期?这里有一个例子(checkdate.php3)

2004-10-01 08:26:10  作者:  来源:互联网  浏览次数:13  文字大小:【】【】【
简介:<html> <body> <? function is_numeric($var){    $str = (string)$var;    $int = (int)$var;    $strstr = (string)$int;    if...

function is_numeric($var){

$str = (string)$var;

$int = (int)$var;

$strstr = (string)$int;

if($strstr==$str) return true;

else return false;

}

function check($year,$month,$day)

{

if(is_numeric($year) and is_numeric($month) and is_numeric($day)){

if(checkdate($month,$day,$year)){

echo $year . "年" . $month . "月" . $day . "日 是合法日期!
";

}

else{

echo $year . "年" . $month . "月" . $day . "日 不是合法日期!
";

}

}

else{

echo $year . "年" . $month . "月" . $day . "日 不是合法日期!
";

}

}

check("1999","1","1");

check("2000","2","31");

check("1900","2","1");

check("1900.2","2","1");

check("aaa","1","1");

?>

责任编辑:admin
相关文章