1 Star2 Stars3 Stars4 Stars5 Stars (7 votes, average: 5.00 out of 5)

Php 7 While Loop Repeat Different Information Dynamically | Lesson 19

In a “Php 7 While Loop” you can repeat different information dynamically when you compare it to a variable. A While loop will execute when a condition is “TRUE” in other words “matches the variable”. Here is what we are going to be learning in this lesson.

  • While
  • Do While

The Php features we will be using are:

  • “=” to set a Php variable
  • “while()” A Php Loop
  • “do{}while()” A Php Loop that executes a condition after the statement
  • “<=” Less than or equal to Conditional Operator
  • “++” Increment Operator, adds to a variable

Files for this lesson.

Subscribe To My YouTube Channel:

Php 7 While Loop *

In a Php 7 while loop we first need to set a variable. We are going to use this variable to compare conditions too. You will recall that we learned about “Conditional Statements” in a previous lesson. Here is an example of a simple “While Loop”.

$var=10;
while($var <= 10 ){
echo '

The loop says '.$var.'

';
$var++;
}

The while loop will echo out the numbers in consecutive order. The loop will keep adding 1 because of the “increment” operator. When the loop reaches the number 10 it will stop because of the Conditional Statement “<=”.

Php 7 Do While Loop *

The “Php 7 Do While Loop” will execute a statement first then it will start incrementing the numbers. We will explain this further on the next page. Here is a simple way to write a “do while loop” in Php.

$var=1; 
do{ 
echo ' The loops says '.$var.' '; 
$var++; 
}while($var <= 10 );

continue on next page.

Php 7 While Loop Repeat Different Information Dynamically | Lesson 19 was last modified: November 28th, 2018 by Maximus Mccullough

Advanced Programming Made Easy

I hope you enjoyed the article. If I was able to help you please consider a tip for the content.

One Time Tip

more tips

Reoccuring Tips

Tips

Php 7 While Loop Repeat Different Information Dynamically

Pages: 1 2 Next

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.