我是php的新手。用这个试验了很多。我写了另一个代码。但它在第26行显示错误。我无法找到问题。请检查一下,告诉我问题是什么。 的 result.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>
答案 0 :(得分:8)
问题是
{int}
应该是
(int)
答案 1 :(得分:3)
也许你应该改变
$yob={int} $_POST["yob"];
为此:
$yob=(int) $_POST["yob"];