Key Concepts

Review core concepts you need to learn to master this subject

PHP break keyword

// We can use the break statement to end the loop once the count reaches 4 $count = 1; while ($count < 10) { echo "The count is: " . $count . "\n"; if ($count === 4) { break; } $count += 1; }

In PHP, break can be used to terminate execution of a for, foreach, while or do…while loop.

One downside of heavy usage of break statements is that code can become less readable.

Loops
Lesson 1 of 2

What you'll create

Portfolio projects that showcase your new skills

Pro Logo

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo