Well, you might want to do it with curl, you might want to write your
own socketscript, or your just check the return variable of
file_get_contents() - it'll be false on failure and it won't try to
get an invalid URL forever. Guess the error is somewhere else, when
your script continues indefinitely.
I'm using theis function in that way with a daily cronjob, and the
remote server isn't so stable... trust me. ;)
But setting the timeout can be done in php.ini or like suggested on
the php.net manual:
2009/4/7 Skip Evans <s...@bigskypenguin.com>:
> Hey all,
> I'm doing some maintenance work on an existing system and there is a piece
> of code that uses file_get_contents() to read data from a URL, which is fine
> in theory I suppose.
> But the problem is sometimes the server where that URL lives is not
> available, and the system hangs indefinitely.
> Shouldn't this be done with curl, and if so can it be done so that the call
> will time out and return control back when the server is not available?
> Any other recommendations?
> I just came across this code and it's one of the client's biggest
> Skip Evans
> Big Sky Penguin, LLC
> 503 S Baldwin St, #1
> Madison WI 53703
> Those of you who believe in
> telekinesis, raise my hand.
> -- Kurt Vonnegut
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php