Skip to content
Readerstacks logo Readerstacks
  • Home
  • Softwares
  • Angular
  • Php
  • Laravel
  • Flutter
Readerstacks logo
Readerstacks

Break and Continue statements

Aman Jain, July 18, 2021July 18, 2021

Break and continue statements are used to change the flow of program. lets see the difference and usage of both.

Break as the name implies it terminate the current loop and execute the next line of code.

Continue do not terminate the loop rather then it skip the current iteration and execute next itteration.

Example of break:

for ($i = 1; $i <= 5; $i++) {
  
    // Program comes out of loop when
    // i equals to 2.
    if ($i==2)
        break;
    else
        echo($i);
}
echo "\n Program finish";

Output :

1
Program finish

it will check if $i== 2 then it will stop execution of for loop and will process next line of code.

Example of continue:

for ($i = 1; $i <= 5; $i++) {

    // The loop prints all values except 2
 
    if ($i==2)
        continue;
    else
        echo $i.",";
}
echo "\n Program finish";

Output :

1,3,4,5,
Program finish

it will check if $i== 2 then it will skip this iteration and will process next iteration of for loop.

Related

Softwares

Post navigation

Previous post
Next post

Related Posts

Softwares disable change detection anagular

How to disable automatic change detection strategy in angular component?

July 4, 2021November 8, 2023

In angular all components by default take the changes as any event occur, but sometime we disable automatic change detection strategy in angular. Thus, to detach the two way binding in component we can use changeDetection strategy in component metadata. Angular Change Detection Strategy is simple to implement using the…

Read More

What is apache web server and install on ubuntu?

August 28, 2021August 29, 2021

Apache is a web server which is used to serve the http request from a client computer. A client can open a webpage to view the website using web browsers like chrome, firefox etc. and browsers sent their requests to web servers like apache http server. How to install Apache…

Read More
Angular angular file upload

How to upload files with form data in angular 12?

June 20, 2021November 8, 2023

in this tutorial we will learn to upload files with form data in angular. it’s not easy to upload the files along with form data in angular in compare to JQuery and other JavaScript framework. Angular upload a form in JSON and some time it get difficult to obtain the…

Read More

Aman Jain
Aman Jain

With years of hands-on experience in the realm of web and mobile development, they have honed their skills in various technologies, including Laravel, PHP CodeIgniter, mobile app development, web app development, Flutter, React, JavaScript, Angular, Devops and so much more. Their proficiency extends to building robust REST APIs, AWS Code scaling, and optimization, ensuring that your applications run seamlessly on the cloud.

Categories

  • Angular
  • CSS
  • Dart
  • Devops
  • Flutter
  • HTML
  • Javascript
  • jQuery
  • Laravel
  • Laravel 10
  • Laravel 11
  • Laravel 9
  • Mysql
  • Php
  • Softwares
  • Ubuntu
  • Uncategorized

Archives

  • July 2025
  • June 2025
  • May 2025
  • April 2025
  • October 2024
  • July 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • July 2023
  • March 2023
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021

Recent Posts

  • Mapping Together: The Vibrant Spirit of OpenStreetMap Japan
  • Understanding High Vulnerabilities: A Deep Dive into the Weekly Summary
  • Building a Million-Dollar Brand: The Journey of Justin Jackson
  • Mastering Schedule Management with Laravel Zap
  • The Resilience of Nature: How Forests Recover After Fires
©2023 Readerstacks | Design and Developed by Readerstacks
Go to mobile version