-1

我是php新手。对此进行了很多实验。我写了另一个代码。但它在第 26 行显示错误。我无法找到问题所在。请检查一下并告诉我问题出在哪里。 结果.php

    <?php
if (isset ($_POST["name"])){
    $name=$_POST["name"];
}
if(isset ($_POST["yob"])){
    $yob=(int) $_POST["yob"];
}
if(isset ($_POST["wifename"])){
    $wifename=$_POST["wifename"];
}
if(isset ($_POST["wyob"])){
    $wyob= (int) $_POST["wyob"];
}
$currentyear=date("Y");
if($yob>=$currentyear){
    echo "Sorry {$name} you have not born yet.";
}
if($currentyear>$yob){
    $husbandage=$currentyear-$yob;
}
if($wyob>=$currentyear){
    echo "Sorry {$name} your mother in law is still virgin.";
}
else{$wifeage=$currentyear-$wyob;}
if($husbandage>$wifeage){
    echo "You are {"$husbandage-$wifeage"} years older than your wife";
}
if($husbandage<$wifeage){
    echo "You are {$wifeage-$husbandage} years older than your wife";}
    if($husbandage==$wifeage){
        echo "You and your wife are same age";}

?>

年龄计算器.php

<html>
<title>Age Difference Calculator</title>
<body>
<form action="result.php" type="post">
    Your Name: <input type="text" name= "name"><br/>
    Year Of Birth: <input type= "text" name:"yob"><br/>
    Your Wife's Name: <input type="text" name="wifename"><br/>
    Your Wife's Year Of Birth: <input type="text" name="wyob"><br/>
    <input type="submit">
</form> 
</body>
</html>
4

2 回答 2

8

问题是

{int}

它应该是

(int)
于 2013-04-28T23:50:21.207 回答
3

也许你应该改变

$yob={int} $_POST["yob"];

为了这:

$yob=(int) $_POST["yob"];
于 2013-04-28T23:51:00.980 回答