Alternative syntax in PHP
Today I read the wordpress code, which contains some rare alternative php syntax,
'' . __( 'Pages:', 'thebox' ), 'after' => '' ) ); ?>
What do the colons and endif after else represent? I have never met a cainiao, so I just googled it to understand that this is an alternative syntax for php,
Colon (:) is equivalent to left curly braces ({), and endif is equivalent to right curly braces (});
For example:
Is a negative number.
The preceding statement is equivalent
Is a negative number.
Which of the following statements in PHP have alternative syntaxes?
Process control (including if, while, forforeach, switch) statements have alternative syntax.
The basic form of alternative Syntax:
Replace left curly braces ({) with colons (:), and change right curly braces (}) with endif;, endwhile;, endfor;, endforeach; and endswitch;
While alternative Syntax:
Loop point
Other Alternative syntaxes can be similar.