PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
josh
DevNet Master
Posts: 4872 Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida
Post
by josh » Fri Dec 17, 2004 1:24 pm
Correct me if I am wrong, shouldn't the following code time out after 3 seconds, so if the file I am reading from doesn't exist it will give up instead of freezeing up
Code: Select all
<?php
$xml = '';
$time=time();
$File=fopen($uFile, "rb");
while (!feof($File) AND $time+3>$time) {
$xml .= fread(uFile, 8192);
}
fclose($File);
?>
A site I was getting an xml data feed from went down and I noticed my code wasn't working, was my server just lagging or is there an error in my code.
Thank you in advance
Joe
Forum Regular
Posts: 939 Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow
Post
by Joe » Fri Dec 17, 2004 1:42 pm
Not sure here but try:
Code: Select all
<?php
$xml = '';
$time=time();
$File=fopen($uFile, "rb");
while (!feof($File)) {
if ($time+3>$time) break;
$xml .= fread(uFile, 8192);
}
fclose($File);
?>
rehfeld
Forum Regular
Posts: 741 Joined: Mon Oct 18, 2004 8:14 pm
Post
by rehfeld » Fri Dec 17, 2004 2:15 pm
$time+3 will always be greater than $time
you want $time+3>time()
josh
DevNet Master
Posts: 4872 Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida
Post
by josh » Fri Dec 17, 2004 2:39 pm
Opps my bad, when you type code at like 2 AM you tend to make stupid mistakes like putting the variable $time instead of the function time().... heh
If only computers did what you want them to do instead of what you tell them to do