The break Statement PHP

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. shows this in action.

Leaving a Loop Using break

<?
while(true)
{
print("This line is printed.");
break;
print("This line will never be printed.");
}

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

PHP Topics