Refinansiering | Hiiri | Kredittkort Rabatt | Billigste Strømleverandør 2018 | Hyttealarm Pris 2018 | Vardia Forsikring Test | Beste Mobilabonnement 2018 | Rørlegger

Php break statement tutorial

Written by Tusher

for, while, do while loop, and looping statements to a switch statement in the case of special conditions are met and the break statement is used to come out of the loop.

Practice Project

body{background: #00cc99 ; color: #000000;}

echo “<h2>Example of break statement</h2>”;
for($i; $i<10; $i++)
echo ” I = “.$i;
echo “<br >”;



After writing the above Kodak a nptepad click the File menu, click Save as index.php in the File name in the Save as type, select All files by clicking on the Save to Save. indexer file C: \ example \ htdocs should be in the htdocs folder. Htdocs folder to the Desktop Shortcut to the action easily could be put in. If XAMPP Running index.php file in the browser address bar to show the will to write http: //localhost/index.php. And if a new folder in the htdocs folder create a folder named as the site of the index.php file is to write to the browser’s address bar http: //localhost/site/index.php. If the browser look like the image below.

  • $ I = 0; A variable must be declared in the for loop.
  • for ($ i; $ i <10; $ i ++) for the loop has been set for the conditions. At the beginning of the variable $ i will be 0; $ I ++ $ i variable for each loop will be increased by one; $ I <10; 9. That will be a maximum value of $ i. That is a total of 10 times will lunatic.
  • if ($ i == 5) 5. If it is expressed in the value of $ i will work testamentary between {} else {} If any value between Erie testamentary go away.
  • if ($ i == 5) {break;} 5. If released in the value of $ i {} After entering the break; So to be able to be finished lunatic statement for the program will be out of the loop for control.
  • for ($ i; $ i <10; $ i ++), and pursuant to the terms lunatic run 10 times the value of $ i will be 0 to 9, but the break; As a statement of the value of $ i is a maximum of 5.
  • echo “I =”. $ i; Expressing similar to the browser, I = 4 $ i variable will be displayed.
  • $ I = 5 in the case of the break; Statement is effective for the $ i = 5 echo “I =”. $ I; Does not work . At the end of the browser piratical I = 0 I = 1 I = 2 I = 3 I = 4 is shown.

About the author