Home > php教程 > php手册 > body text

解析PHP对现有搜索引擎的调用

WBOY
Release: 2016-06-13 11:45:12
Original
870 people have browsed it

复制代码 代码如下:


    $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;
    }
?>


运行结果如图36-4所示。


图36-4  PHP综合搜索引擎

单击【Submit】按钮后,可以看到Yahoo网站被打开了,并搜索到了相关的搜索结果,如图36-5所示。


图36-5  Yahoo的搜索结果

source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!