代码如下 | 复制代码 |
$dm = 'www.111cn.net'; $ip = gethostbyname($dm); echo gethostbyaddr($ip); echo $ip; |
//两个输出结果是一样的,
/*
关于 gethostbyname语法
string gethostbyname ( string $hostname )
返回由主机名指定的互联网主机的ipv4地址
returns the ipv4 address of the internet host specified by hostname
下面有个例这是最好的方法我已经提出,以解决任何主机名称到ip地址时,它的快速,可靠,已超时的支持!一个无效的地址,例如unicode字符串,返回后4?秒,而不是8调用gethostbyname?!它只能与unix虽然。
*/
代码如下 | 复制代码 |
function getaddrbyhost($host, $timeout = 3) { $query = `nslookup -timeout=$timeout -retry=1 $host`; if(preg_match('/ address: (.*) /', $query, $matches)) return trim($matches[1]); return $host; } |
/*
gethostbyaddr 是获取internet主机名对应一个特定的ip地址
代码如下 | 复制代码 |
string gethostbyaddr ( string $ip_address ) |
*/
代码如下 | 复制代码 |
$hostname = gethostbyaddr($_server['remote_addr']); echo $hostname; |
本站原创教程转载www.111cn.net

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Linux new version
SublimeText3 Linux latest version

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.
