第十一例,年龄计算器
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2019/9/19 0019
* Time: 12:46
*/
if (!empty($_POST)){
$time = mktime(0,0,0,intval($_POST['mouth']),0,intval($_POST['year']));
date_default_timezone_set('Asia/shanghai');
$age = floor((time()-$time)/3600/24/365);
echo "<script>alert('您的年龄是{$age}岁');</script>";
}else{
echo "<script>alert('请输入内容');</script>";
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title&g