Home >Backend Development >PHP Tutorial >php网站来路获取代码(针对搜索引擎)_php技巧

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

WBOY
WBOYOriginal
2016-05-17 09:24:44917browse
复制代码 代码如下:

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