From the course: PHP for Non-Programmers

Unlock the full course today

Join today to access over 25,200 courses taught by industry experts.

Allowing for multiple flips

Allowing for multiple flips - PHP Tutorial

From the course: PHP for Non-Programmers

Allowing for multiple flips

- [Instructor] All right, now let's elaborate on our original program and ask the user if they want to flip again. It's important to mention that there are a lot of different ways to implement this. If you did yours different from the way I'm doing mine, that doesn't mean one is right or wrong as long as they both fulfill the requirements we laid out. So let's go ahead and prompt the user. Okay, so I am going to add a variable up here called $keep_going. And I'm going to set this to y at first because we want this to flip at least once. Then we know that if we want to complete a repeatable task or create a repeatable task, we'll need a loop. So I'll say while and then the condition we want to check for is if the user inputs a lower case y, we want them to keep going. So I'll say while y equals $keep_going and then we'll put our if statement inside the while loop. Now this is important. This is why we set $keep_going to…

Contents