Home >Backend Development >PHP Tutorial >Detailed explanation of php calls to existing search engines

Detailed explanation of php calls to existing search engines

怪我咯
怪我咯Original
2017-07-04 15:02:501822browse

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[&#39;key&#39;];                        //获得关键字 
    $select = $_GET[&#39;select&#39;];                  //获得搜索引擎的选择 
    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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn