As "qbolec" states, all the notes below which use the "?" are actually references to the ternary operator (http://uk.php.net/operators.comparison").
Whilst this is kind of relevent, it probably shouldn't be in this section.
流程控制的替代语法PHP 提供了一些流程控制的替代语法,包括 if,while,for,foreach 和 switch。替代语法的基本形式是把左花括号({)换成冒号(:),把右花括号(})分别换成 endif;,endwhile;,endfor;,endforeach; 以及 endswitch;。 在上面的例子中,HTML 内容“A is equal to 5”用替代语法嵌套在 if 语句中。该 HTML 的内容仅在 $a 等于 5 时显示。 替代语法同样可以用在 else 和 elseif 中。下面是一个包括 elseif 和 else 的 if 结构用替代语法格式写的例子:
atw
04-Nov-2006 08:47
As "qbolec" states, all the notes below which use the "?" are actually references to the ternary operator (http://uk.php.net/operators.comparison").
qbolec
16-Oct-2006 05:33
I don't find some of the previous posts to be referencing this particular article.
Neil
30-Sep-2006 03:08
as skippy noted above this is very useful stuff for interspersed php & html. Here is alternative syntax example using a bitwise comparison to set checkboxes on and off to prefill a permissions bitmask calculator form:
davidforest at gmail dot com
20-Oct-2005 09:26
If you need a tidy way to do a lot of condition testing, switch statement will do the job well:
skippy at zuavra dot net
27-Jun-2005 07:32
If it needs saying, this alternative syntax is excellent for improving legibility (for both PHP and HTML!) in situations where you have a mix of them.
siebe-tolsma at home dot nl
19-Mar-2004 02:22
As a rection on sttoo, if you use nested if's a bit different they are less likely to cause mistakes:
i a m 4 w e b w o r k at hotmail dot com
13-Oct-2003 07:38
Good tutorial on using alternative control structure syntax at:
paul at example dot com
06-Sep-2003 09:27
There is an other alternative syntax: | ||