Home > php教程 > PHP源码 > body text

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

WBOY
Release: 2016-06-08 17:28:54
Original
1083 people have browsed it

根据域名调用城市信息[全国二级域名]
本文章为你做一个页面,根据用户输入的域名调用不同城市的信息
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;
   }
  }
 }

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!