PHP provides some alternative syntax for process control, including if, while, for,foreach , and switch. The basic form of substitution syntax is to replace the left curly brace ({) with a colon (:) and the right curly brace (}) into endif;,endwhile;,endfor;,Endforeach; and Endswitch;.
<php if ($a = = 5 ): ? >is to5<php endif; ? >
In the example above, the HTML contents "A is equal to 5" are nested in an if statement with an alternate syntax. The contents of the HTML are $a displayed only at equals 5 o'clock.
Alternative syntax can also be used in else and ElseIf . The following is an example of an if structure, including ElseIf and else , written in alternate syntax format:
<? PHP if $a = = 5): echo "a equals 5 " ; echo " ..." ; ElseIf $a = = 6): echo "a equals 6 " ; echo "!!!" ; else: echo "A is neither 5 nor 6" ; endif ;? >
Note: It is not supported to mix two syntaxes within the same control block.
Use and or replace if else
isset($aa) andPrint("AA is set") orisset($as) andPrint("As is set") orPrint("as Not set");//equivalent toif(isset($aa)) Print("AA is set");ElseIf(isset($as)) Print("As is set");Else Print("as Not set");
Alternative notation for Process Control