I was wondering if there is a way so that if file_get_contents has a problem reading a URL page that it will not crash the php script. So like on error just continue or skip. I am using PHP 4.4.4
Thanks...
Error checking for file_get_contents
Moderator: General Moderators
-
realtime158
- Forum Newbie
- Posts: 14
- Joined: Mon Nov 20, 2006 9:09 pm
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Last I checked, file_get_contents() outputs a warning upon encountering problems. This does not stop execution.
Per the manual you can set the timeout value..
But I'd recommend you just use curl instead.
Code: Select all
ini_set('default_socket_timeout', 120);
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Note: file_exists() only supports URLs in PHP 5+.
Edit: However, user comments on the page supply potential url_exists() functions that work similarly. Some do require PHP 5, so be careful.
Edit: However, user comments on the page supply potential url_exists() functions that work similarly. Some do require PHP 5, so be careful.