<html>
<body>
<form action="" method="GET">
Name: <input type="text" name="name" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>
</body>
</html>
<?php
if($_GET["name"] || $_GET["age"])
{
echo "Welcome ". $_GET['name']. "<br />";
echo "You are ". $_GET['age']. " years old.";
}
?>
,當我在上面瀏覽器中打開腳本,它顯示:注意:Undefined index: name in D:\wamp\www\oop\test3.php on line 13,
我知道,如果是因爲表單尚未提交,因此$_GET["name"]
做不存在,但如何解決這個問題?
[?參考 - 這是什麼錯誤PHP意味着]可能重複(http://stackoverflow.com/questions/12769982/reference-what-does-這個錯誤意味着在php) –
你有沒有嘗試我的例子/答案我給你下面,任何機會? –