Home  >  Article  >  Backend Development  >  php网站来路获取代码(针对搜索引擎)_PHP

php网站来路获取代码(针对搜索引擎)_PHP

WBOY
WBOYOriginal
2016-06-01 12:18:38933browse
复制代码 代码如下:
function get_referer(){
$se = 0;
$url = $_SERVER["HTTP_REFERER"]; //获取完整的来路URL
$str = str_replace("http://","",$url); //去掉http://
$strdomain = explode("/",$str); // 以“/”分开成数组
$domain = $strdomain[0]; //取第一个“/”以前的字符
if(strstr($domain,'baidu.com')){
$se = 1;
}
else if(strstr($domain,'google.cn')){
$se = 1;
}
return $se;
}
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