我有一个页面,我试图让我的搜索框执行操作。当有搜索时,我有3个网站:Google,wiki和duckduckgo。当我将页面上传到服务器时,我收到语法错误。我从来没有在PHP中做过if语句。我看着w3schools中的教程,我仍然感到困惑。我试过冒号和大括号,我仍然感到困惑。如果语句在PHP试图冒号和花括号仍然需要帮助
有人能给我一个正确的方向?
<form action="search.php" method="get">
<?php
$site = substr(filter_input(INPUT_GET, 'site', FILTER_SANITIZE_STRING), 0, 8);
$terms = substr(filter_input(INPUT_GET, 'terms', FILTER_SANITIZE_STRING), 0, 25);
if ($site=="google") header('Location:https://www.google.com/#q=' . $terms); {
}else{
if ($site=="Wikipedia")header ('Location:https://www.wikipedia.org/#q=' . $terms); {
} else ($site=="DuckDuckGo")header ('Location:https://duckduckgo.com/#q=' .$terms);
endif;
}
}
?>
参见手册关于if语句:http://php.net/manual/en/control-structures.if.php – Rizier123
@tawanna:你应该检查,如果在进入这里之前,还有其他PHP语法。 –