We all have mundane, repetitive tasks we have to do.
You know, like putting stamps on all those holiday greeting cards we send out every year?
Well, from a programming angle, PHP can help us ease the workload on repetitive tasks in websites with a LOOP.
The first one we’ll discuss is the WHILE LOOP.
It sounds like a weird carnival ride (I got sick on the While Loop - it was great!) but it is one of the most useful loop functions in PHP.
Logically, it looks like this:
while ( this conditional statement is true){
//do this;
}
This isn’t real code - just an illustration of how it works. now, here’s what happens, step by step:
1. PHP checks the conditional statement. If it is true, move to step 2. If it is false, go to step 4.
2. PHP runs the code contained in the loop.
3. We go back to step 1 and start again, making a LOOP.
4. Once the conditional statement becomes false, the loop exits, and code placed after the loop runs.
1 Comment
Jagruti
9/4/2008 09:14:33 pm
Reply
Leave a Reply. |
David Rentson
If this free PHP and MYSQL Tutorial is helpful for you... Great! Archives
October 2008
Categories
All
|