Copy Code code as follows:
<?php
$key = $_get[' key ']; Get keywords
$select = $_get[' select ']; Get the Search engine choice
Switch ($select)//jump to a different page depending on the search engine
{
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
Default://If the search engine does not exist, end the program
Break
}
?>
The results of the operation are shown in Figure 36-4.
Figure 36-4 PHP Comprehensive search engine
When you click the "Submit" button, you can see that the Yahoo site is open and search for relevant search results, as shown in Figure 36-5.
Figure 36-5 Yahoo's search results