<?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;
}
?>
运行结果如图36-4所示。
图36-4 php综合搜索引擎
单击【submit】按钮后,可以看到yahoo网站被打开了,并搜索到了相关的搜索结果,如图36-5所示。
图36-5 yahoo的搜索结果
如对本文有疑问,
点击进行留言回复!!
网友评论