梳理数字但不在PHP中添加它们

Cla*_*ado 2 html php validation

我正在尝试对用户选择的日期和当前日期进行服务器端验证,这是我拥有的:

$day = $_POST['day'];
$month = $_POST['month'];
$year = $_POST['year'];
$dateval = $year + $month + $day;

if ($dateval - $today < 0) {
$datepassed = 'no';
}
else {
$datepassed = 'yes';    
}
Run Code Online (Sandbox Code Playgroud)

据我所知,除了$ dateval变量只是将所有数字相加而不是将它们组合在一起以形成用户选择的日期之外,所有内容都完美无缺.例如20110719返回2037.如何在不添加数字的情况下组合数字?任何帮助表示赞赏.

Al *_*l W 6

如果要将它们连接为字符串,请使用点(.)

$dateval = $year . $month . $day;
Run Code Online (Sandbox Code Playgroud)

但是,由于您正在使用日期,请考虑使用mktime函数

$dateval = mktime(0, 0, 0, $month, $day, $year)
Run Code Online (Sandbox Code Playgroud)