PHP Break, Continue Control Statement !!
Break
The Break statement used in loops for bring the program control out of loops.
Break condition is used for break the loop for a certain condition.block out of loop will execute correctly.
In short,after break statement the loop is terminated and no code of loop is execute.
Break statements use in if-else, switch, for, while, do-while control statements.
Break Statement In For Loop
In code of for loop there is condition if that condition is true then break will execute and terminate the loop.
Syntax :
for (initialization; condition; increment/decrement)
{
condition for break
{
break
}
code of for loop
Program :
Output :
1
2
3
Work :
Here, we take a = 1 initially, loop will occur till a become 5.
First time it prints 1, after that 2 and then 3 when a become 4 if condition become true and break will execute.
After break execute for loop terminate.
Break Statement In While Loop
When we want to know the number of iteration and want to perform simple program then we can use break statement.
when we not increment or decrement value on that case we have to use break statement.
Syntax :
while ( condition )
{
code of loop
}
break
Program :
check the given number is 10 or not.
Output :
a is 10
Work :
In this program we only check either given number is 10 or not.
we take number which is 10 then it print 10 otherwise not.
if we not use break statement then the loop is go in infinite loop and code print for infinite time.
so, for execute code only once then we have to use break keyword.
Break With Switch Statement
Break uses for print the particular case.
Program :
Output :
a is 10
As shown in above program we take a variable with value 10.
Switch goes to the case 10 and execute the block after that break will execute and switch terminate.
Continue
Continue statement used work like break statement. the difference is break statement terminate the block and any code will not execute after break.
In, continue statement it takes control out of program for particular condition.
After that remaining code of block will execute.
Continue statement use when a single or particular condition only don't want to be execute.
It also use in loops like if-else, for, while etc..
Syntax :
for (initialization; condition; increment/decrement)
{
condition for continue
}
continue
Program :
Output :
1
2
3 ## only 4 will not print
5
Work :
Range of a is 1 to 5 it means it executes for 5 times.
when a became 4 continue execute, it means it not prints the 4.
all process after and before is same all numbers are print except 4.
In this article we will discuss about break statement with for, while and switch statement.
You Can Also Search For :
- PHP Variables
- Different Data-Types In PHP
- Constants Of PHP
- PHP If-Else Control Statement
- PHP - XML Introduction !!
- Different Frame Works In PHP!!
- PHP Break, Continue Control Statement !!
- PHP Form With GET And POST Method !!
- For Loop Control Statement !!
Mesothelioma Survival Rates , Mesothelioma Attorneys California , Seattle Mesothelioma Lawyer , Mesothelioma Suit , Mesothelioma Claim , Wisconsin Mesothelioma Attorney , Mesothelioma Attorney illinois , Mesothelioma Trial Attorney ,Houston Mesothelioma Attorney , Mesothelioma Lawyer Dallas , New York Mesothelioma Law Firm,Mesothelioma Lawyer Asbestos Cancer Lawsuit , Mesothelioma Lawyers San Diego,Mesothelioma Litigation , Mesothelioma Attorney Assistance , Mesothelioma Lawyer Asbestos Cancer Lawsuit , Mesothelioma Lawyer Chicago , New York Mesothelioma Law Firm ,
Houston Mesothelioma Attorney , Mesothelioma Lawyer Dallas , Mesothelioma Care , Mesothelioma Trial Attorney , Mesothelioma Lawyer Texas , Lawsuit Mesothelioma , Truck Accident Attorney Los Angeles ,Asbestos Exposure Lawyers , Mesothelioma Cases , Emergency Response Plan ppt , Mesothelioma Lawyers San Diego , Asbestos Mesothelioma Lawsuit , Tennessee Mesothelioma Lawyer , Meso Lawyer , Mesothelioma Settlements Amounts , Mesothelioma Law Firms , New Mexico Mesothelioma Lawyer , Accident Attorneys Orange County , Mesothelioma Lawsuit ,Personal Injury Accident Lawyer , Purchase Structured Settlements , Firm Law Mesothelioma , Car Accident Lawyers Los Angeles , Mesothelioma Attorneys , Structured Settlement Company , Auto Accident Lawyer San Francisco , Mesotheolima , Los Angeles Motorcycle Accident Lawyer
Mesothelioma , Mesothelioma Lawyer Virginia , Seattle Mesothelioma Lawyer , Mesothelioma Attorney illinois , Mesothelioma Drug , Mesothelioma Attorney DirectoryMesothelioma Settlements , Mesothelioma Help , Mesothelioma ct , Mesothelioma Attorney Florida , Washington Mesothelioma Attorney , Best Mesothelioma Lawyers , Diagnosed With Mesothelioma , Mesothelioma Settlement Amounts , Mesothelioma Personal Injury Lawyers , Mesothelioma Compensation , Attorney Lawyer Mesothelioma ,Colorado Mesothelioma Lawyers,Mesothelioma Lawsuits , Mesothelioma Claims , Average Mesothelioma Settlement , Average Mesothelioma Settlement , Mesothelioma Law Suit , Alabama Mesothelioma Lawyer , alabama Mesothelioma Lawyer , utah mesothelioma lawyer , Dallas Mesothelioma Lawyer , Mesothelioma Attorney California , Mesothelioma Lawyer California ,Mesothelioma Survival Rates ,
Mesothelioma Attorneys California, Wisconsin Mesothelioma Attorney Mesotheliama , Mesothelioma Lawyer Virginia , Seattle Mesothelioma Lawyer , Mesothelioma Attorney illinois, Mesothelioma Trial Attorney Injury Lawyer Houston tx , Baltimore Mesothelioma Attorneys , Mesothelioma Care ,Mesothelioma Trial Attorney ,Mesothelioma Lawyer Texas , Mesothelioma Lawyer Dallas , Mesothelioma Care , Mesothelioma Trial Attorney , Mesothelioma Lawyer Texas , California Mesothelioma Attorney Philadelphia Mesothelioma Lawyer , Illinois Mesothelioma Lawyer , Mesothelioma Attorney , Mesothelioma Claims , Average Mesothelioma Settlement
Integrated ehr , Mesothelioma Law Sui , Mesothelioma Lawyer California,Mesothelioma Attorney California ,Mesothelioma Law Suits ,Dallas Mesothelioma Attorneys ,Mesothelioma Drug ,Mesothelioma Attorney Directory