How can I obtain a domain name through an ip address?

Source: Internet
Author: User
How can I obtain a domain name through an ip address ?? I use gethostbyaddr ('put IP' inside); each time only the ip address is returned instead of the domain name. it seems that only 127.0.0.1 can be input to return the domain name, neither Baidu nor Google, how can this function be used !!!! Functiongethost ($ ip) {& How do I get a domain name through ip address ??
I use gethostbyaddr ('put IP' inside); each time only the ip address is returned instead of the domain name. it seems that only 127.0.0.1 can be input to return the domain name, neither Baidu nor Google, how can this function be used !!!!

Function gethost ($ ip)
{
Return (preg_match ('/^ (? : 25 [0-5] | 2 [0-4] \ d | 1 \ d | [1-9] \ d | \ d )(? : [.]
(? : 25 [0-5] | 2 [0-4] \ d | 1 \ d | [1-9] \ d | \ d )) {3} $/', $ ip ))? Gethostbyaddr ($ ip): false;

}

------ Solution --------------------
PHP code
Function getContent ($ url) {$ content = file_get_contents ($ url); return $ content;} function getResult ($ ip) {$ pagesize = 10; $ page = 1; $ url = "http://cn.bing.com/search? Q = ip % 3A $ ip & first = $ page "; $ result = array (); do {$ url =" http://cn.bing.com/search? Q = ip % 3A $ ip & first = $ page "; $ content = getContent ($ url); $ pattern = "/([A-zA-Z0-9 \.] *) (? :\/.*)? <\/Cite>/isU "; preg_match_all ($ pattern, $ content, $ matches); $ result = array_merge ($ result, $ matches [1]); $ nextpage = strpos ($ content, "next page"); $ page = $ page + $ pagesize;} while ($ nextpage ); $ result = array_values (array_unique ($ result); return $ result;} // call method $ result = getResult ("220.181.111.85 "); // $ result = getResult ("117.79.93.222"); // csdnecho"
";print_r($result);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.