jomla Posted December 11, 2016 Share Posted December 11, 2016 (edited) Hi at all I am using file_get_contents but if I work off line it falled (of course) How can I do to prevent fallure? Thank you very much Edited December 11, 2016 by jomla Link to comment Share on other sites More sharing options...
Ingolme Posted December 11, 2016 Share Posted December 11, 2016 I'm not sure what you mean by working offline. You say it failed, what shows up in the browser when it fails? Is there any error message? Link to comment Share on other sites More sharing options...
jomla Posted December 11, 2016 Author Share Posted December 11, 2016 Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Host UNKNOW. in C:\xampp\htdocs\iml.phpon line 204Warning: 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 204Notice: Undefined offset: 0 in C:\xampp\htdocs\iml.php on line 211 Link to comment Share on other sites More sharing options...
Ingolme Posted December 11, 2016 Share Posted December 11, 2016 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now