我正在尝试在我的 Wamp 服务器上执行一个非常简单的 PHP 发布方法,但是当我单击“提交”时,我返回的是我的 PHP 源代码,而不是它应该做的事情。值得一提的是,我在 Wamp 上做了一些简单的测试,它肯定是在阅读 PHP。
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html" />
<meta name="author" content="" />
<title>308 Assigning Values</title>
<link rel="stylesheet" type="text/css" href="css/basic.css" />
</head>
<body>
<form method="post" action="0308_Assigning_Values.php">
<p>
First Name:
<input type="text" name="firstname" size="30"/>
</p>
<p>
Last Name:
<input type="text" name="lastname" size="30"/>
</p>
<p>Your Age:
</p>
<p><input type = "text" name="age" size="3"/></p>
<p><input type="submit" value="Submit Information" />
</p>
</form>
</body>
</html>
--------------------------------------------------------------
<?php
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$fullname = "$firstname $lastname";
$factor = 5;
$ageplus = $age + $factor;
$current_year = date('Y');
$birth_year = $current_year - $ageplus;
print "<p>Your name is $fullname ";
print "<p>and you say your age is $age ";
print "<p>but I bet you are really $ageplus ";
print "<p>and were born in $birth_year</p> ";
?>