简体   繁体   中英

How to get IP from “http://” or “www” in PHP?

How do I get something in PHP/Curl to grab the IP of the URL for me? It's going to be a simple interface that fetches URL IP's back for me.

Eg Enter "http://mysite.com" then I hit submit then I should get the IP of the mysite.com back.

gethostbyname

$ip_string = gethostbyname( "stackoverflow.com" );
echo $ip_string; //returns ip address, ie 12.34.56.78

尝试gethostbyname函数。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM