Copy code The code is as follows:
$key = $_GET['key']; //Get Keywords
$select = $_GET['select']; //Get the search engine selection
switch($select) //Jump to different pages according to different search engines
{
case "google": //GOOGLE
$url = "http://www.google.com/search?q=".$key;
header("Location: $url");
break;
case "yahoo": //YAHOO
$url = "http://search.yahoo.com/search?p=".$key;
header("Location : $url ");
break;
case "baidu": Baidu
$url = "http://www.baidu.com/s?wd=".$key;
header( "Location: $url");
break; ;
The running results are shown in Figure 36-4.
Figure 36-4 PHP comprehensive search engine
After clicking the [Submit] button, you can see that the Yahoo website is opened and relevant search results are found, as shown in Figure 36-5.
Figure 36-5 Yahoo search results
http://www.bkjia.com/PHPjc/327855.html
www.bkjia.com
truehttp: //www.bkjia.com/PHPjc/327855.htmlTechArticleCopy the code as follows: ?php $key = $_GET['key']; //Get keyword $ select = $_GET['select']; //Get the search engine selection switch($select) //Jump to... depending on the search engine