PHP flow control continue statement

不言
Release: 2023-03-25 11:02:01
Original
2210 people have browsed it

This article mainly introduces the continue statement about PHP process control. It has a certain reference value. Now I share it with you. Friends in need can refer to it.

This article is for basic useLearners, experts please close this page

It takes 15 minutes to read this article. It is hard to explain if it is difficult to understand. I encourage you to try it yourself

(PHP 4, PHP 5, PHP 7)

continue is used in the loop structure to skip the remaining code in this loop and start executing the next loop when the condition evaluates to true.

Note: Note that in PHP the switch statement is considered a loop structure that can use continue.

continue accepts an optional numeric parameter to determine how many loops to skip to the end of the loop. The default value is 1, which jumps to the end of the current loop.

\n";
    while (1) {
        echo "Middle
\n"; while (1) { echo "Inner
\n"; continue 3; } echo "This never gets output.
\n"; } echo "Neither does this.
\n"; } ?>
Copy after login

Omitting the semicolon after continue can cause confusion. The following example shows how not to do this.

Copy after login

The desired result is:

0
1
3
4
Copy after login

But the actual output is:

2
Copy after login

Related recommendations:

php flow control break statement

php flow control what is foreach

The above is the detailed content of PHP flow control continue statement. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!