今天看到几个函数,可以根据ip地址 / 域名 获取对应的 域名 / ip 的函数。记录于此。 gethostbynamel($hostname) // 根据 域名 获取 IP,返回一个数组,比如baidu。com,就返回2个ip 说明array gethostbynamel ( string $hostname )Returns a list of IPv4 a
今天看到几个函数,可以根据ip地址 / 域名 获取对应的 域名 / ip 的函数。记录于此。
gethostbynamel($hostname) // 根据域名获取IP,返回一个数组,比如baidu。com,就返回2个ip
说明 array gethostbynamel ( string $hostname ) Returns a list of IPv4 addresses to which the Internet host specified by hostname resolves. 参数 hostname The host name. 返回值 Returns an array of IPv4 addresses or FALSE if hostname could not be resolved.
gethostbyname($hostname) // 根据域名获取IP,只返回第一个IP
gethostbyname — Get the IPv4 address corresponding to a given Internet host name 说明 string gethostbyname ( string $hostname ) Returns the IPv4 address of the Internet host specified by hostname. 参数 hostname The host name. 返回值 Returns the IPv4 address or a string containing the unmodified hostname on failure.
gethostbyaddr($ip) // 根据IP 获取域名
gethostbyaddr — Get the Internet host name corresponding to a given IP address 说明 string gethostbyaddr ( string $ip_address ) Returns the host name of the Internet host specified by ip_address. 参数 ip_address The host IP address. 返回值 Returns the host name on success, the unmodified ip_address on failure, or FALSE on malformed input.
例子:
<span>$hostname</span> = 'www.baidu.com'<span>; </span><span>$addr</span> = '127.0.0.1'<span>; </span><span>print_r</span>(<span>gethostbyname</span>(<span>$hostname</span><span>)); </span><span>echo</span> '<br>'<span>; </span><span>print_r</span>(<span>gethostbyaddr</span>(<span>$addr</span><span>)); </span><span>echo</span> '<br>'<span>; </span><span>print_r</span>(<span>gethostbynamel</span>(<span>$hostname</span>));
输出
220.181.111.148 idc-wang Array ( [0] => 220.181.111.148 [1] => 220.181.112.143 )

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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 Chinese version
Chinese version, very easy to use

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),

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function