I need a function that I can use in my script to contact another script to send it some GET data. But I need to be able to set a timeout so that it only loads for a few seconds, then continues with the rest of the script. I know I could easily use cURL to do this, but I’d like to know if there are any alternatives?
Share
You can specify a timeout for the standard file access functions (like
file_get_contents()) usingstream_context_create():See the list of context options for an explanation on the
timeoutoption.This requires, of course, that you can access external URLs using
fopen()and consorts.