M
M
mrSeller2018-03-23 14:20:07
PHP
mrSeller, 2018-03-23 14:20:07

The file_get_contents() function throws an error, but the verification fails - what to do?

I make a request

file_get_contents("http://api.sypexgeo.net/json/". $_SERVER['REMOTE_ADDR'])
to get geodata about the user, but at the moment something happened and the address http://api.sypexgeo.net/json/became unavailable, which is why I get this error:
"file_get_contents(): php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known"

The PHP docs describe that in case of an error, the function returns false, but the construction if (file_get_contents()) {}still gives the same error.
How to solve problems?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Burov, 2018-03-23
@mrSeller

filte_get_contents returns false
error can be hidden using error control statement

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question