We often see a lot of strange php syntax in the wordpress template of a blog program, such as:
[PHP]View Plaincopy
- <?phpif(Empty($GET _[' A ']):?>
- <font color=" Red " > Empty </font>
- <?php endif;?>
for a considerable part of the PHP enthusiasts have never seen, what are these things? In fact, these are PHP Process control alternative syntax, but not commonly used.
The following will give you a detailed look at the PHP Process Control alternative syntax.
1. What is an alternative syntax?
in short, it is some kind of grammatical alternative notation.
What syntax in 2.PHP has an alternative syntax?
If,while,for,forforeach,switch These Process control statements have alternative syntax.
3. The basic form of alternative syntax:
The left Curly brace ({) is replaced by a colon (:) and the right curly brace (}) is replaced by Endif;,endwhile;,endfor;,endforeach; and Endswitch;
Example:
[PHP]View Plaincopy
- <? php if ( $ A <0): ?>
- is a negative pull
- <?php endif
- The above statement is equivalent to
- <?php if ( $a <0) { ?>
- is negative pull
- <?php}?>
4. We're not used to it, and what's the use of such an alternative?
existence is reasonable, it has its own usefulness, these grammars can be played in the PHP and HTML mixed page code inside. The benefits are as follows:
1) make the HTML and PHP Mix page code cleaner and neater.
2) The Process control logic is clearer and the code is easier to read.
PHP: Colon, endif, Endwhile, endfor