Please tell me why this code forms infinite loop
<?php
$temp = 1;
while($temp<=10)
{
echo "The no is : " . $temp . "<br>";
$temp = $temp++;
}
?>
Why this code forms infinite loop ...
Moderator: General Moderators
-
sjohnranjan
- Forum Newbie
- Posts: 1
- Joined: Tue Jan 15, 2008 10:27 pm
Re: Why this code forms infinite loop ...
$temp++ returns $temp and THEN increments it
try $temp = ++$temp;
or simply..
$temp++;
try $temp = ++$temp;
or simply..
$temp++;
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Re: Why this code forms infinite loop ...
See http://us3.php.net/manual/en/language.o ... rement.php for why, and more examples.