TheDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
break statement is a control flow structure used to prematurely terminate the execution of the current enclosing for, foreach, while, do-while, or switch block. When encountered, the PHP runtime immediately halts the iteration or evaluation of the current structure and transfers execution to the statement immediately following the terminated block.
Syntax
Mechanics and Behavior
- Execution Transfer:
breakunconditionally jumps out of the active loop or switch construct. It does not terminate the script, nor does it break out of standard conditional statements likeif(unless theifstatement is nested within a loop orswitch). Note that becausematchis an expression and its arms strictly require expressions, it is syntactically impossible to place abreakstatement directly inside amatchconstruct. - Nesting Level Argument:
breakaccepts an optional positive integer argument that specifies how many nested enclosing structures are to be terminated. If omitted, the default value is1, meaning it will only break out of the immediate enclosing structure. - Argument Constraints: The argument passed to
breakmust be a constant integer literal (e.g.,break 2;). Passing variables or dynamically evaluated expressions (e.g.,break $levels;) is invalid and will result in a fatal error.
Syntax Visualization
Single-Level Break Terminates only the immediate enclosing structure.Master PHP with Deep Grasping Methodology!Learn More





