Course Content
Introduction
PHP is an object-oriented scripting programming language that allows web developers to create dynamic and interactive web pages. PHP stands for Hypertext Preprocessor (PHP).
0/14
Control Statement
A control statement is a statement that determines whether other statements will be executed.
0/7
PHP for Beginners
About Lesson

The while loop executes a block of code repeatedly until the condition is FALSE.

Syntax:

while (condition is true) {
  	code to be executed;
}

Example:

$number = 1;
while($num <= 5) {
  	echo "The number is: $num 
";
  	$num++;
}
  • $num = 1; – Initialize the loop counter ($num), and set the start value to 1
  • $num <= 5 – Continue the loop as long as $num is less than or equal to 5
  • $num++; – Increase the loop counter value by 1 for each iteration