Home >Backend Development >PHP Tutorial >Detailed explanation of php calls to existing search engines
This article is a detailed analysis and introduction of PHP's calls to the existing search index. Friends in need can refer to it
The code is as follows:
<?php $key = $_GET['key']; //获得关键字 $select = $_GET['select']; //获得搜索引擎的选择 switch($select) //根据搜索引擎的不同跳转到不同的页面 { 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": //百度 $url = "http://www.baidu.com/s?wd=".$key; header("Location: $url"); break; default: //如果搜索引擎不存在,结束程序 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 were found, as shown in Figure 36-5.
Figure 36-5 Yahoo search results
The above is the detailed content of Detailed explanation of php calls to existing search engines. For more information, please follow other related articles on the PHP Chinese website!