break

Used to exit out of a loop code block

 

Next statement following the loop will then be executed

Displays:

$myVar is currently 0
$myVar is currently 1
$myVar is currently 2
$myVar is currently 3
$myVar is currently 4
$myVar is currently 5
$myVar is currently 6
The if condition executed the break when $myVar evaluated to 7

Leave a Reply