![]() The continue statement skips the remaining lines of code inside the loop and start with the next iteration. when a continue statement is encountered inside the loop, remaining statements are skipped and loop proceeds with the next iteration. The continue statement in php is used to bring the program control to the beginning of the loop. The break is commonly used in the cases where we need to break the loop for a given condition. The break statement breaks the loops one by one, i.e., in the case of nested loops, it breaks the inner loop first and then proceeds to outer loops. when a break statement is encountered inside a loop, the loop is terminated and program control resumes at the next statement following the loop. The break is a keyword in php which is used to bring the program control out of the loop. In PHP, the following are jump statements Jump statements in PHP are used to alter the flow of a loop like you want to skip a part of a loop or terminate a loop. The for loop is mostly used in the case where the number of iterations is known in advance.įor (initialization condition increment/decrement) With the for loop we can execute a set of statements specified number of times. The do-while loop will always execute a set of statements atleast once and then execute a set of statements as long as a condition is true. The while loop is mostly used in the case where the number of iterations is not known in advance. With the while loop we can execute a set of statements as long as a condition is true. In PHP, the following are loop statements If the execution of a specific code may need to be repeated several numbers of times then we can go for loop statements. Sometimes we may need to alter the flow of the program. ![]() The switch statement enables us to execute a block of code from multiple conditions depending upon the expression. ![]() The elseif statement enables us to check multiple conditions and execute the specific block of statements depending upon the true condition among them. The if-else statement provides an else block combined with the if statement which is executed in the false case of the condition. If the condition is true, a block of code (if-block) will be executed. The if statement is used to test a specific condition. In PHP, the following are conditional statements These statements are mainly categorized into following:Ĭonditional Statements performs different computations or actions depending on conditions. If condition evaluates to a value that doesn't match any of the case: labels, and the default: label is not present, then none of the statements in the switch body is executed.The Control Structures (or) Statements used to alter the execution process of a program. If condition evaluates to a value that doesn't match any of the case: labels, and the default: label is present, control is transferred to the statement labeled with the default: label. If condition evaluates to a value that is equal to the value of one of constant-expressions, then control is transferred to the statement that is labeled with that constant-expression. At most one default: label may be present (although nested switch statements may use their own default: labels or have case: labels whose constants are identical to the ones used in the enclosing switch). The body of a switch statement may have an arbitrary number of case: labels, as long as the values of all constant-expressions are unique (after conversions/promotions). case: and default: labels are permitted in statement and break statement has special meaning.Īttr (optional) case constant-expression : statementĪ constant expression of the same type as the type of condition after conversions and integral promotions If the (possibly converted) type is subject to integral promotions, condition is converted to the promoted type.Īny statement (typically a compound statement). The value of condition must be of integral or enumeration type, or of a class type contextually implicitly convertible to an integral or enumeration type.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |