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

<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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools