tags:

views:

339

answers:

1

hi experts, when i am using file_get_contents function to get the url in to string i am getting the following error. how can i solve this in my localhost ?

$contents = file_get_contents("http://google.com");

file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: No such host is known.

thanks.

+3  A: 

Your "localhost" cannot resolve the name google.com to an ip address, which means your machine doesn't/can't reach a valid dns server.
This probably doesn't only affect php. Try ping google.com on the console of that machine. Does this complain about the unknown host, too?
The steps necessary to solve the problem depend on what your "localhost" is (operating system, flavour/distribution, ...) and how it is connected to the internet.

VolkerK
when i give ping google.com it says unknown host. i check with my host. thanks.
paulrajj