Nest nesting
The curly braces curly braces
Colon syntax colon syntax
PHP Three if the wording of the judgment
Writing one:
if (true) {
}else if () {
}else if () {
}else{}
Two:
if () {
}elseif () {
}elseif () {
}else{}
Three:
if ():
#执行语句
ElseIf
#执行语句
ElseIf
#执行语句
Else
#执行语句
endif
Alternative syntax for Process Control
PHP provides a number of alternative syntax for process Control,
Includes If,while,for,foreach and switch.
The basic form of substitution syntax is to replace the left curly brace ({) with a colon (:),
Replace the right curly brace (}) with Endif;,endwhile;,endfor;,endforeach; and Endswitch;.
Note:
It is not supported to mix two syntaxes within the same control block.
Echo and print are statement structures, not functions, and cannot be used as callback functions
But print always returns 1.
Foreach
A reference to a $value is available only if the array being traversed can be referenced (for example, a variable). The following code does not work:
It is easy to modify the elements of an array by adding & before $value. This method assigns a value to a reference instead of copying a value.
Warning
The $value reference of the last element of the array remains after the Foreach loop. It is recommended to use unset () to destroy it.
Unpack nested arrays with list ()
(PHP 5 >= 5.5.0, PHP 7)
PHP 5.5 adds the ability to iterate through an array of arrays and unpack the nested array into a loop variable by simply supplying the list () as a value.
The cells in list () can be less than the nested arrays, and the extra array cells are ignored:
If more cells are listed in list () than nested arrays, a message-level error message is emitted:
Added: Declare, require, require_once, include, Include_once?????????????????
PHP's Process Control