Jump to content

unable to prevent error if I work offline


jomla

Recommended Posts

Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Host UNKNOW. in C:\xampp\htdocs\iml.phpon line 204

Warning: file_get_contents(http://www.sant.com/day.txt): failed to open stream: php_network_getaddresses: getaddrinfo failed: Host sconosciuto. in C:\xampp\htdocs\iml.php on line 204

Notice: Undefined offset: 0 in C:\xampp\htdocs\iml.php on line 211

Link to comment
Share on other sites

You can't get files from the internet if you're not connected to the internet. You could download day.txt and host it on your own server.

 

If you want to prevent an error message you can use the error suppression operator "@" and use the return value of the function to determine that it failed.

$data = @file_get_contents($url);
if($data === false) {
  echo 'Unable to open file.';
}
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...