我试图避免未定义的索引。我也使用过 isset,但我无法获得预期的结果。
<body>
<FORM NAME ="form1" METHOD ="POST" ACTION = "test.php">
<INPUT NAME = "search" size="74">
<INPUT TYPE = "Submit" Name = "SearchButton" VALUE = "Search">
</FORM>
<?php
$search = isset($_POST['search']);
//$search = $_POST['search'];
if (!isset($_GET[$search])) {
// category isn't set
echo 'not set';
}
else {
echo 'set';
}
?>