Jump to content

Need help with While loops and frames


BreakBreak

Recommended Posts

I'm trying to keep a page open and looping for testing purposes of a further project.

I have 4 frames

They are all running while loops with a sleep(1) in them

They are all doing the following:

$i = 2;
$z = 1;
while($i > 1){

echo "$z second <br>";
sleep(1);
$z++;
}

However, for some perculiar reason, three of them stop SOMETIMES after 20 or so seconds, whilst the one to the farthest right carries on.

What baffles me is that SOME of them only stop SOMETIMES.

Another confusion, once it ran with all four of them counting for over 30 minutes and showed no sign of stopping.

PHP is NOT in safe mode.


---------

Please help me as this is slowing me down hugely and i need to find a solution, fast.
Link to comment
https://forums.phpfreaks.com/topic/24099-need-help-with-while-loops-and-frames/
Share on other sites

This works: [code]<?php
while(1)
{
sleep(1);
$i++;
echo "{$i} seconds\n";
}
?>[/code]

Output (command-line):
[code]daniel@daniel:~$ php /var/www/test.php
1 seconds
2 seconds
3 seconds
4 seconds
5 seconds
6 seconds
7 seconds
8 seconds
9 seconds

daniel@daniel:~$[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.