0

我想知道,有哪些:使用案例?

我只知道:

if(expression):
    // do Something
endif;

while(expression):
    // and others: `for` `foreach` etc.
endwhile;

还有其他用途吗?

4

4 回答 4

5

PHP 为它的一些控制结构提供了另一种语法;即 , if, while, for,foreachswitch。在每种情况下,备用语法的基本形式是将左大括号更改为冒号 ( :),将右大括号分别更改为endif;, endwhile;, endfor;, endforeach;, or endswitch;

http://us3.php.net/manual/en/control-structures.alternative-syntax.php

于 2012-05-18T16:29:48.497 回答
4

三元条件:($a == $b) ? true : false.
类内的静态调用:self::$a.
静态方法调用:MyClass::MyMethod()
类内的静态变量:MyClass::MyVariable
父方法调用:parent::hello()

于 2012-05-18T16:31:28.117 回答
3

switch将其用于case 123:default:

::用于访问静态类成员。

于 2012-05-18T16:30:52.580 回答
2

它也用作三元运算符“?:”的一部分。

http://php.net/manual/en/language.operators.comparison.php

于 2012-05-18T16:32:23.490 回答