Monday, November 23
Trending
- AI-Powered Cyberattacks in 2026: How Hackers Use AI Agents
- US Outages Explained: What Happened to Microsoft, FAA and Banks
- Microsoft 365 Outage: Outlook, Teams and Copilot Down. What We Know
- Diwali Online Shopping Scams 2026: 10 Ways to Stay Safe
- 10 Best DDoS Protection Services for 2027
- 12 Best Web Application Firewalls (WAF) for 2027
- Best Ethical Hacking Tools in 2027: Free & Paid Picks
- Software supply chain attacks 2026: Timeline and developer checklist
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



