我想知道,:
使用的情况是什么?
我只知道:
if(expression):
// do Something
endif;
while(expression):
// and others: `for` `foreach` etc.
endwhile;
还有其他用途吗?
PHP 为它的一些控制结构提供了另一种语法;即
if
、while
、for
、foreach
和switch
。在每种情况下,替代语法的基本形式是将左大括号分别改为冒号(:
(,将右大括号改为endif;
、endwhile;
、endfor;
、endforeach;
或endswitch;
。
http://us3.php.net/manual/en/control-structures.alternative-syntax.php
三元条件:($a == $b) ? true : false
.
类内的静态调用:self::$a
。
静态方法调用:MyClass::MyMethod()
,
类中的静态变量:MyClass::MyVariable
父方法调用:parent::hello()
switch
将其用于case 123:
和default:
。
::
用于访问静态类成员。
它也用作三元运算符"?:"的一部分。
http://php.net/manual/en/language.operators.comparison.php