Loop Problem
Posted: Wed May 25, 2005 2:42 pm
I have a loop that checks a file for a value, if the value is 1, do something:
Which works fine, as soon as I update the value of 0 in the file to 1, it shows the text.
The problem is that if I have launched the page, I cannot go anywhere else on my site, it just hangs. And if the file value was indeed 1, and I refresh the page. It executes the php before the html is shown, so the user would see the previous html and not the new html.
What can be done to get around this problem?
Code: Select all
if (file_exists($file_name))
{
while (true)
{
$read = file($file_name);
$read = $read[0];
if ($read == 0)
{
sleep(5);
}
else
{
echo "Worked!!!";
}
}
}The problem is that if I have launched the page, I cannot go anywhere else on my site, it just hangs. And if the file value was indeed 1, and I refresh the page. It executes the php before the html is shown, so the user would see the previous html and not the new html.
What can be done to get around this problem?