第11例
index.php页面:
年龄计算器
出生年份:
出生月份:
出生那天的号数:
date.php页面:
$year=$_POST['year'];//获取年份
$month=$_POST['month'];//获取月份
$day=$_POST['day'];//获取日期
$bithday=mktime(0,0,0,$month,$day,$year);//转化为时间戳毫秒数
$nowUNIX=time();//获取现在的时间戳毫秒数
$age=$nowUNIX-$bithday;
$age=floor($age / (365*24*60*60));//时间戳毫秒数转化为年月日
echo "
echo "alert('您的年龄为:".$age."');";
echo "";
?>
第12例
图片1
图片2
图片3
function check(obj)
{
var src=obj.value;
$("shoetime").src=src;
}
function $(obj)
{
return document.getElementById(obj);
}
第13例
date_default_timezone_set('PRC');
echo "中国北京时间:";
echo date("y-m-d h:i:s")."
";
date_default_timezone_set('America/New_York');
echo "美国纽约时间:";
echo date("y-m-d h:i:s")
?>
第14例
function check()
{
if(document.myform.text.value=="")
{
alert("内容不能为空");
return false;
}
return true;
}
if(!empty($_POST['text']))
{
$str=$_POST['text'];
preg_match_all("/./us",$str,$match);
$num=count($match[0]);
if($num<=10)
{
echo "
}else{
echo "
}
}
?>
第15例
index.php页面
header.php页面
文件引用*{
margin: 0px;
padding: 0px;
}
div{
margin: auto;
}
footer.php页面