Hướng dẫn what is use of continue in php? - việc sử dụng tiếp tục trong php là gì?

(Php 4, Php 5, Php 7, Php 8)

continue được sử dụng trong các cấu trúc vòng lặp để bỏ qua phần còn lại của lần lặp vòng lặp hiện tại và tiếp tục thực hiện ở mức đánh giá điều kiện và sau đó bắt đầu lần lặp tiếp theo.

Lưu ý: Trong Php, câu lệnh chuyển đổi được coi là một cấu trúc vòng lặp cho các mục đích của continue. continue hành xử như break (khi không có tranh luận nào được thông qua) nhưng sẽ đưa ra cảnh báo vì đây có thể là một sai lầm. Nếu một switch nằm trong một vòng lặp, continue 2 sẽ tiếp tục với lần lặp tiếp theo của vòng ngoài.: In PHP the switch statement is considered a looping structure for the purposes of continue. continue behaves like break (when no arguments are passed) but will raise a warning as this is likely to be a mistake. If a switch is inside a loop, continue 2 will continue with the next iteration of the outer loop.

continue chấp nhận một đối số số tùy chọn cho biết nó có bao nhiêu mức các vòng lặp bao quanh mà nó sẽ bỏ qua đến cuối. Giá trị mặc định là 1, do đó bỏ qua cuối vòng lặp hiện tại.

foreach ($arr as $key => $value) {
    if (!(
$key 2)) { // skip even members
        
continue;
    }
    
do_something_odd($value);
}
$i 0;
while (
$i++ < 5) {
    echo 
"Outer\n";
    while (
1) {
        echo 
"Middle\n";
        while (
1) {
            echo 
"Inner\n";
            continue 
3;
        }
        echo 
"This never gets output.\n";
    }
    echo 
"Neither does this.\n";
}
?>

Bỏ qua dấu chấm phẩy sau continue có thể dẫn đến sự nhầm lẫn. Đây là một ví dụ về những gì bạn không nên làm.

continue0

Người ta có thể mong đợi kết quả là:

Thay đổi cho continue
Phiên bảnSự mô tả
7.3.0 continue trong một switch đang cố gắng hành động như một tuyên bố break cho switch sẽ kích hoạt continue6.continue6.

Jaimthorn tại Yahoo Dot Com ¶

12 năm trước

continue7

continue8

continue9

continue0

continue1

continue2

continue3

continue4

Nikolay Ermolenko

13 năm trước

continue5

continue6

continue7

continue8

Koen ¶

9 năm trước

continue9

rjsteinert.com

11 năm trước

break0

break1

continue4

www.derosetechnology.com

18 năm trước

break3

break4

break5

break6

break7

continue4

Greg tại Laundrymat.tv ¶

17 năm trước

break9

switch0

switch1

switch2

switch3

switch4

switch5

continue4

Tufan dot oezduman tại gmail dot com ¶

15 năm trước

switch7

switch8

continue4

Clau r Jimenez ¶

1 năm trước

continue 20

continue 21

continue 22

continue4

Người đam mê ¶

14 năm trước

continue 24

continue 25

continue4

MPARSA1372 tại Gmail Dot Com ¶

1 năm trước

continue 27

continue 28

continue 29

continue4

Người đam mê ¶

11 năm trước

continue1

continue2

continue4

www.derosetechnology.com

18 năm trước

continue4

continue5

continue6

continue4

Greg tại Laundrymat.tv ¶

17 năm trước

continue8

continue9

10

11

12

13

Người đam mê ¶

14 năm trước

14

MPARSA1372 tại Gmail Dot Com ¶

17 năm trước

15

16

17

continue4

Tufan dot oezduman tại gmail dot com ¶

15 năm trước

19

foreach ($arr as $key => $value) {
    if (!(
$key 2)) { // skip even members
        
continue;
    }
    
do_something_odd($value);
}
$i 0;
while (
$i++ < 5) {
    echo 
"Outer\n";
    while (
1) {
        echo 
"Middle\n";
        while (
1) {
            echo 
"Inner\n";
            continue 
3;
        }
        echo 
"This never gets output.\n";
    }
    echo 
"Neither does this.\n";
}
?>
0

foreach ($arr as $key => $value) {
    if (!(
$key 2)) { // skip even members
        
continue;
    }
    
do_something_odd($value);
}
$i 0;
while (
$i++ < 5) {
    echo 
"Outer\n";
    while (
1) {
        echo 
"Middle\n";
        while (
1) {
            echo 
"Inner\n";
            continue 
3;
        }
        echo 
"This never gets output.\n";
    }
    echo 
"Neither does this.\n";
}
?>
1

Clau r Jimenez ¶

1 năm trước

foreach ($arr as $key => $value) {
    if (!(
$key 2)) { // skip even members
        
continue;
    }
    
do_something_odd($value);
}
$i 0;
while (
$i++ < 5) {
    echo 
"Outer\n";
    while (
1) {
        echo 
"Middle\n";
        while (
1) {
            echo 
"Inner\n";
            continue 
3;
        }
        echo 
"This never gets output.\n";
    }
    echo 
"Neither does this.\n";
}
?>
2

foreach ($arr as $key => $value) {
    if (!(
$key 2)) { // skip even members
        
continue;
    }
    
do_something_odd($value);
}
$i 0;
while (
$i++ < 5) {
    echo 
"Outer\n";
    while (
1) {
        echo 
"Middle\n";
        while (
1) {
            echo 
"Inner\n";
            continue 
3;
        }
        echo 
"This never gets output.\n";
    }
    echo 
"Neither does this.\n";
}
?>
3

foreach ($arr as $key => $value) {
    if (!(
$key 2)) { // skip even members
        
continue;
    }
    
do_something_odd($value);
}
$i 0;
while (
$i++ < 5) {
    echo 
"Outer\n";
    while (
1) {
        echo 
"Middle\n";
        while (
1) {
            echo 
"Inner\n";
            continue 
3;
        }
        echo 
"This never gets output.\n";
    }
    echo 
"Neither does this.\n";
}
?>
4

foreach ($arr as $key => $value) {
    if (!(
$key 2)) { // skip even members
        
continue;
    }
    
do_something_odd($value);
}
$i 0;
while (
$i++ < 5) {
    echo 
"Outer\n";
    while (
1) {
        echo 
"Middle\n";
        while (
1) {
            echo 
"Inner\n";
            continue 
3;
        }
        echo 
"This never gets output.\n";
    }
    echo 
"Neither does this.\n";
}
?>
5

foreach ($arr as $key => $value) {
    if (!(
$key 2)) { // skip even members
        
continue;
    }
    
do_something_odd($value);
}
$i 0;
while (
$i++ < 5) {
    echo 
"Outer\n";
    while (
1) {
        echo 
"Middle\n";
        while (
1) {
            echo 
"Inner\n";
            continue 
3;
        }
        echo 
"This never gets output.\n";
    }
    echo 
"Neither does this.\n";
}
?>
6

Người đam mê ¶

17 năm trước

foreach ($arr as $key => $value) {
    if (!(
$key 2)) { // skip even members
        
continue;
    }
    
do_something_odd($value);
}
$i 0;
while (
$i++ < 5) {
    echo 
"Outer\n";
    while (
1) {
        echo 
"Middle\n";
        while (
1) {
            echo 
"Inner\n";
            continue 
3;
        }
        echo 
"This never gets output.\n";
    }
    echo 
"Neither does this.\n";
}
?>
7

foreach ($arr as $key => $value) {
    if (!(
$key 2)) { // skip even members
        
continue;
    }
    
do_something_odd($value);
}
$i 0;
while (
$i++ < 5) {
    echo 
"Outer\n";
    while (
1) {
        echo 
"Middle\n";
        while (
1) {
            echo 
"Inner\n";
            continue 
3;
        }
        echo 
"This never gets output.\n";
    }
    echo 
"Neither does this.\n";
}
?>
8

foreach ($arr as $key => $value) {
    if (!(
$key 2)) { // skip even members
        
continue;
    }
    
do_something_odd($value);
}
$i 0;
while (
$i++ < 5) {
    echo 
"Outer\n";
    while (
1) {
        echo 
"Middle\n";
        while (
1) {
            echo 
"Inner\n";
            continue 
3;
        }
        echo 
"This never gets output.\n";
    }
    echo 
"Neither does this.\n";
}
?>
9

continue0

continue1

continue2

continue3

continue4

Tufan dot oezduman tại gmail dot com ¶

17 năm trước

continue5

continue6

continue7

continue8

continue9

continue4

Tại sao chúng ta sử dụng tiếp tục trong PHP?

Tuyên bố tiếp tục PHP được sử dụng để tiếp tục vòng lặp. Nó tiếp tục luồng hiện tại của chương trình và bỏ qua mã còn lại ở điều kiện được chỉ định. Câu lệnh tiếp tục được sử dụng trong cấu trúc vòng lặp và chuyển đổi khi bạn ngay lập tức nhảy sang lần lặp tiếp theo.to continue the loop. It continues the current flow of the program and skips the remaining code at the specified condition. The continue statement is used within looping and switch control structure when you immediately jump to the next iteration.

Vai trò của tiếp tục là gì?

Tuyên bố tiếp tục chuyển quyền kiểm soát đến lần lặp tiếp theo của phần gần nhất, cho hoặc trong khi câu lệnh trong đó xuất hiện, bỏ qua bất kỳ câu lệnh còn lại trong DO, cho hoặc trong khi cơ thể câu lệnh.passes control to the next iteration of the nearest enclosing do , for , or while statement in which it appears, bypassing any remaining statements in the do , for , or while statement body.

Việc sử dụng phá vỡ và tiếp tục trong PHP là gì?

Tuyên bố Break chấm dứt toàn bộ lần lặp của một vòng lặp trong khi tiếp tục bỏ qua lần lặp hiện tại.Tuyên bố Break chấm dứt toàn bộ vòng lặp sớm trong khi việc tiếp tục mang lại lần lặp tiếp theo sớm.. The break statement terminates the whole loop early whereas the continue brings the next iteration early.

Làm thế nào sử dụng tiếp tục trong nếu điều kiện trong PHP?

Tiếp tục được sử dụng trong các cấu trúc vòng lặp để bỏ qua phần còn lại của lần lặp vòng lặp hiện tại và tiếp tục thực hiện ở mức đánh giá điều kiện và sau đó là bắt đầu lần lặp tiếp theo.Lưu ý: Trong Php, câu lệnh chuyển đổi được coi là một cấu trúc vòng lặp cho các mục đích tiếp tục.. Note: In PHP the switch statement is considered a looping structure for the purposes of continue .