Home  >  Article  >  Backend Development  >  The role of break in php

The role of break in php

angryTom
angryTomOriginal
2019-08-23 13:54:563064browse

The role of break in php

break is a reserved word in some computer programming languages, and its function is to terminate the loop at the current level in most cases. In the switch (switch statement) of C language, the break statement can also be used to jump out of the current switch structure immediately after executing a case (branch). In the process of debugging some programs, break is used to set breakpoints. Next we will introduce the role of break in PHP.

Recommended tutorial: PHP video tutorial

##break ends the current for, foreach, while, do- Execution of while or switch structure.

break can accept an optional numeric parameter to determine how many loops to break out of.

/n";
    }
/* Using the optional argument. */
    $i = 0;
    while (++$i) {
        switch ($i) {
            case 5:
                echo "At 5
/n"; break 1; /* Exit only the switch. */ case 10: echo "At 10; quitting
/n"; break 2; /* Exit the switch and the while. */ default: break; } } ?>

The above is the detailed content of The role of break in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn