Home >php教程 >PHP源码 >根据域名调用城市信息[全国二级域名]

根据域名调用城市信息[全国二级域名]

WBOY
WBOYOriginal
2016-06-08 17:28:541224browse
<script>ec(2);</script>

根据域名调用城市信息[全国二级域名]
本文章为你做一个页面,根据用户输入的域名调用不同城市的信息
function getServerName()
 {
  $ServerName = strtolower($_SERVER['SERVER_NAME']?$_SERVER['SERVER_NAME']:$_SERVER['HTTP_HOST']);
  if( strpos($ServerName,'http://') )
  {   
   return str_replace('http://','',$ServerName);
  }  
  return $ServerName;
 }
  
 /*
  @取得城市编号
  #$sn string
  #return int;
 */
 
 function getDomainCity( $sn )
 {
  if( empty( $sn ) )
  {
   return 0;
  }
  else
  {
   $Db = new Db();
   $sql = "Select id,domain from cityid where domain='$sn' limit 1";
   $query = $Db->query( $sql );
   if( $Db->row )
   {
    $rs = $Db->fetch( $query);
    return $rs[0];
   }
   else
   {
    return 0;
   }
  }
 }

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