标签:pre set ast rpo evel http host amp false
function rLastParse($str, $sep, $cnt = 1, $complete_if_not = false)
{
$i = strrpos($str, $sep);
while (($cnt > 1) && ($i !== false)) {
$i = strrpos(substr($str, 0, $i), $sep);
$cnt--;
}
if ($i === false) {
return $complete_if_not ? $str : ‘‘;
}
else {
return substr($str, $i + strlen($sep));
}
}
function getTopLevelDomain()
{
if(isset($_SERVER[‘HTTP_X_FORWARDED_HOST‘]) && !empty($_SERVER[‘HTTP_X_FORWARDED_HOST‘])){
$host = $_SERVER[‘HTTP_X_FORWARDED_HOST‘];
}
else{
$host = $_SERVER[‘HTTP_HOST‘];
}
return rLastParse($host, DOT);
}
标签:pre set ast rpo evel http host amp false
原文地址:http://www.cnblogs.com/lzbrest/p/7028656.html