<body>
<?
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 . "日 是合法日期!<br>";
}
else{
echo $year . "年" . $month . "月" . $day . "日 不是合法日期!<br>";
}
}
else{
echo $year . "年" . $month . "月" . $day . "日 不是合法日期!<br>";
}
}
check("1999","1","1");
check("2000","2","31");
check("1900","2","1");
check("1900.2","2","1");
check("aaa","1","1");
?>
</body>
</html>
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/