为什么elseif条件不起作用?

时间:2014-02-15 04:48:58

标签: php

<?php

    $datetime=date("d-m-y");
    $date1=date("d")+1;             
    $datetime1=date("$date1-m-y ");
    $date1=$date1+1;
    $datetime2=date("$date1-m-y ");
    $date1=$date1+1;
    $datetime3=date("$date1-m-y ");

    echo $_POST['date1'];
    echo $datetime1;


    if($_POST['date1']==$datetime1)
    {
        header("location:bus2.php");
    }

?>

此处如果条件不起作用,即使echo $_POST['date1'];echo $datetime1;显示相同的结果。

1 个答案:

答案 0 :(得分:7)

NOT 相同:

$datetime1=date("$date1-m-y ");
                           ^--this space makes all the difference:


$_POST['date1'] = '14-02-2014';
$datetime1      = '14-02-2014 ';
                             ^--- spot the difference