如果条件不检查条件

时间:2014-04-22 11:59:00

标签: php if-statement

function pokemon2()
{
    include 'details.php';

    $damage = $_POST['attack']; 
    $oppo_health = $_SESSION['oppo_health']; 
    if($oppo_health < 0)
    {
        echo "Died!"; 
    }
    else
    {
        $oppo_path = $_SESSION['path'];
        echo "<br />";
        echo $oppo_path;
        echo "<br />"; 
        $oppo_health = $oppo_health - $damage;
        echo $oppo_health;
        $_SESSION['attack'] = $damage; 
        $_SESSION['oppo_health'] = $oppo_health;
    }
}

如果$oppo_health低于0,代码应显示'Died'! 但它没有发生,因为它应该??逻辑是正确的,没有显示错误。

1 个答案:

答案 0 :(得分:0)

您需要使用session_start()方法启动会话。