: This article mainly introduces PHP: Colon, endif, endwhile, and endfor. For more information about PHP tutorials, see. We often see many strange PHP syntaxes in the templates of wordpress blog programs, such:
[Php] view plaincopy
-
- "Red"> empty
-
For a considerable number of PHP enthusiasts, what are these things? In fact, these are alternative syntaxes for PHP process control, but they are not commonly used.
The following describes the alternative syntax of PHP process control.
1. what is an alternative syntax?
Simply put, it is an alternative way of writing some syntaxes.
2. what syntax does PHP have?
If, while, for, forforeach, and switch process control statements have alternative syntaxes.
3. basic form of alternative syntax:
Replace Left curly braces ({) with colons (:), and change right curly braces (}) with endif;, endwhile;, endfor;, endforeach; and endswitch;
Example:
[Php] view plaincopy
-
- Is a negative number.
-
-
- The preceding statement is equivalent
-
- Is a negative number.
-
4. everyone is not used to it. what is the purpose of this alternative?
Existence is reasonable, and it has its own use. these syntaxes can be used in the code of PHP and HTML hybrid pages. Benefits:
1) make the HTML and PHP mixed page code more clean and tidy.
2) the process control logic is clearer and the code is easier to read.
The above introduces PHP: Colon, endif, endwhile, endfor, including some content, hope to be helpful to friends who are interested in PHP tutorials.