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
tawfiq
Forum Newbie
Posts: 21 Joined: Sun Jan 27, 2008 12:19 pm
Post
by tawfiq » Wed Sep 09, 2009 6:17 am
Code: Select all
for($i=1;$i<=2;$i++){
if($i = 1){
echo "<br/>we are here for you";
}
}
It's running forever constantly displaying the message. I expected the msg to be displayed just once. What am I missing?
Mark Baker
Forum Regular
Posts: 710 Joined: Thu Oct 30, 2008 6:24 pm
Post
by Mark Baker » Wed Sep 09, 2009 6:27 am
is resetting the value of $i every iteration. use
instead
= means assign a value to a variable
== means comparison
tawfiq
Forum Newbie
Posts: 21 Joined: Sun Jan 27, 2008 12:19 pm
Post
by tawfiq » Wed Sep 09, 2009 6:35 am
how stupid of me not to know that
Thanks a ton