Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

While loop and do while loop ? im confused

Hi! What is difference between while Loop and do while loop in PHP ? Im confused when you would use it and whats the difference i know its do while but what is the point and all of this?

2 Answers

Lets give you an simple example. while "i am sleeping", keep your eyes on my bike. and Do keep your eyes open while "i am sleeping". While loop check the work started first then it execute, and do while start the task and continue until the condition stopped. suppose, While loops start the work after the instruction start. but the do while loops start the work and finish until the instructed process end.

i understand it more now , thank you all :)

While loop and do while loop main difference are while loop is check condition based of boolean value its going execute such of codes.but in case of do while loop its going to execute once by any how either the value is true or false. I am not php but based of c++ lang I think It will be same hope its help