If
if () { statement;} else if { statement;} elseif { statement;} else { statement;}
else if and elseif syntactic analysis have a slightly different meaning, but the bottom line is that they produce exactly the same behavior
Cycle
while () { statement;} do { statement;} and (); for (;;) { statement;} foreach (AS) { statement;}
Break, continue
Can accept an optional numeric parameter to decide to jump out of a few loops
Switch
Switch () {case : statement; Default: statement;}
Allow colons to be substituted for case statements using semicolons
Switch ($beer) {case ' tuborg '; Case ' Carlsberg '; Case ' Heineken '; Echo ' Good choice '; break; default; Echo ' Please make a new selection ... '; break;}
Declare
The declare structure is used to set execution instructions for a piece of code.
Currently only two commands are known: Ticks and encoding
Ticks
Tick (clock cycle) is an event that occurs in the declare code snippet when an interpreter executes an N-timed low-level statement. The value of N is specified in the directive section of declare with Ticks=n.
Not all statements can be timed. Neither the conditional expression nor the parameter expression is timed.
The tick represents an event in which the event is defined in Register_tick_function, and the frequency at which the event is executed is at (ticks=n).
Use, triggering an event every time a few statements are executed, such as logging an event. This allows you to check the execution speed of PHP code within the declare. You can find the code snippet location where the slower part occurs.
'; } }? >
Result of Operation:
1ticksticks4ticksticks9ticksticks16ticksticks25ticksticks36ticksticks49ticksticks64ticksticks81ticksticksticksticks
First, the complete for Loop calculates a statement, but must wait until the end of the loop, so the echo in the for loop at compile time is the first statement.
So the first doticks is executed after the first echo, that is, the first tick event occurs after the 1 output.
In loops x from 1 to 9, each loop consists of two statements, one echo, and one for loop. After the 81 output, because ECHO is a statement, the first ticks is output. At the same time x=9 this for loop also ends, this is another statement, the output of the second ticks, start the $x=10 loop, but this is not satisfied with the loop condition, the For loop execution ends, this loop is a statement, then the output of the third ticks.
Finally declare itself is counted as a statement, so the fourth ticks is output.
Encoding
You can use the encoding directive to specify how each script is encoded
Reutrn require, include, require_once, include_once
Require and include are almost exactly the same, in addition to handling failures differently. Require generates an E_COMPILE_ERROR level error when an error occurs. In other words, the script aborts and the include generates only warnings (e_warning), and the scripts continue to run.
Goto
The goto operator can be used to jump to another location in the program. The target location can be marked with a colon for the target name, and the jump instruction is the mark after Goto followed by the target location.
There are certain restrictions on Goto in PHP, where the target location can only be in the same file and scope, that is, you cannot jump out of a function or class method, or you can skip into another function. You cannot jump into any loop or switch structure. You can jump out of a loop or switch, usually using Goto instead of a multi-layered break.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.