O'Reilly logo

Core PHP Programming: Using PHP to Build Dynamic Web Sites by Leon Atkinson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The break Statement

When a break statement is encountered, execution jumps outside the innermost loop or switch statement. You've seen that this is essential to the usefulness of switch statements. It also has some application for loops. There are cases when you need to leave a loop block somewhere in the middle. Listing 3.6 shows this in action.

Listing 3.6. Leaving a Loop Using break
<?
  while(true)
  {
    print("This line is printed.");
    break;
    print("This line will never be printed.");
  }
?>

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required