Why infinate loop, why?

Codes here !

Moderators: egami, macek, gesf

Post Reply
NigelRen
php-forum Fan User
php-forum Fan User
Posts: 622
Joined: Fri Aug 05, 2011 9:53 am

Thu Aug 02, 2012 11:41 pm

One thing - if you where in an infinite loop - you wouldn't get any of your page back. The server would still think it's building the page to be displayed.
So I think the page is coming back - but your probably getting an error on the page. Have a look in your error logs and see if you can see anything in there ( if using LAMP - the Apache error log should contain this information ).

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 973
Joined: Mon Oct 01, 2012 12:32 pm

Thu Oct 11, 2012 9:13 am

NigelRen wrote:One thing - if you where in an infinite loop - you wouldn't get any of your page back. The server would still think it's building the page to be displayed.
So I think the page is coming back - but your probably getting an error on the page. Have a look in your error logs and see if you can see anything in there ( if using LAMP - the Apache error log should contain this information ).
That's not accurate, if you have buffered output on, and output statements to the screen in your infinite loop, statements will be written as the buffer threshold is met and the buffer dumped. This can be demonstrated with the following code. A couple of caveats, this code was someone else's from viewtopic.php?f=2&t=21059 . It is only an infinite loop because it ignores the exit condition, and it's a poor implementation of a while loop. Only reproducing it to show that you can get output from an infinite loop.

Code: Select all

<?php
$i=0;
$j=5;
while($j==5)
{echo $i;
echo ",";
$i=$i+.2;
if($i==2)
{break;}
?>

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 4 guests