/    Sign up×
Community /Pin to ProfileBookmark

reduce the timeout for a page not found

is there any way with PHP to reduce the timeout for a page not found. I’m checking some external URLs and sometimes the script fails when the URL is no longer valid…

.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMay 22.2008 — How are you checking those URLs? If using cURL functions, there are some cURL options you can set for timeout lengths.
Copy linkTweet thisAlerts:
@esmauthorMay 22.2008 — alas, I'm not using cURL. just file_get_contents.


.
Copy linkTweet thisAlerts:
@NogDogMay 22.2008 — You could try this:
[code=php]
$timeout = 5; // seconds
ini_set('default_socket_timeout', $timeout);
$result = @file_get_contents('http://somesite.com/page.html');
if($result === false)
{
echo "Connection not established after $timeout seconds.";
}
else
{
// do whatever you want to do with $result.
}
[/code]
×

Success!

Help @esm spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...