|
| ||||||||||
| Tags: do while, loop, php, programming language |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| How to use Do-While Loop in PHP?
I am new to the PHP programming language. I want to know about the do-while loop that is used in PHP. I have used that loop before but in other programming language. There should be some different way to use it in PHP. So thought to ask you guys, since you explain the topic more clearly. Please tell me how to use Do-While Loop in PHP? I am not so good in PHP, so please explain me in simple language.!! ![]() |
|
#2
| ||||
| ||||
| Re: How to use Do-While Loop in PHP?
You can run the piece of code again and again by using the while loop in PHP. I would like to explain you about the while loop so that you can understand the basic concept very clearly. The while loop is the easiest way to implement a loop in PHP. This loop behaves the same way as in C. The simplest example of a while loop is as follows : PHP Code:
__________________ IF you hate me, please don't mention it. I know who hates me and who doesn't. You really do not have to make fun of people.... |
|
#3
| ||||
| ||||
| Re: How to use Do-While Loop in PHP?
Even I am explaining you more about the while loop because once you know about the while loop, you can easily understand the do-while loop. The meaning of a while statement is simple. It tells PHP to execute the nested statement(s) repeatedly, as long as the while expression evaluates to TRUE. The value of the expression is checked each time at the beginning of the loop, so even if this value changes during the execution of the nested statement(s), execution will not stop until the end of the iteration. You should know that each time PHP runs the statements in the loop is one iteration. Sometimes, if the while expression evaluates to FALSE from the very beginning, the nested statement(s) won't even be run once.
__________________ Signatures reduce available bandwidth |
|
#4
| ||||
| ||||
| Re: How to use Do-While Loop in PHP?
As with the if you can group multiple statements within the same while loop by grouping them within parentheses or by using the following syntax : PHP Code:
__________________ I do to dead flowers what people at morgues do to dead people. Suck all the moisture out, dip them in plastic, paint them up pretty and put them in a nice frame. |
|
#5
| ||||
| ||||
| Re: How to use Do-While Loop in PHP?
The do-while loops are very similar to while loops, but the expression is checked at the end of each iteration rather than the beginning. The main difference from regular while loops is that the first iteration of the do-while loop is always executed where the expression is checked at the end of the iteration, which is not the case when you use a while loop. The condition is checked at the beginning of each iteration, and if it is FALSE from the very beginning, the loop will be stopped immediately.
__________________ "When they give you ruled paper, write the other way..." J.R.J. |
|
#6
| ||||
| ||||
| Re: How to use Do-While Loop in PHP?
The following is the syntax for do-while loops : PHP Code: |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "How to use Do-While Loop in PHP?" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Watercooling: Single loop or Dual Loop | Akolekar | Hardware Peripherals | 3 | 21-10-2011 10:52 PM |
| Reboot Loop in Windows 7 Reboot loop and Safe mode doesn't work | mADiRAkSHii | Operating Systems | 4 | 25-01-2011 06:23 PM |
| How to use For-Each Loop in PHP? | Bigga Lexx | Software Development | 5 | 06-03-2010 12:16 AM |
| Which is best for iterator: For loop or while loop | Leeland | Software Development | 4 | 18-01-2010 05:03 PM |
| Differentiate between Do-While loop and While loop | REDBULL | Software Development | 3 | 26-11-2009 09:10 AM |