-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";}

?>

agecalculator.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 に答える