I'm wondering, what are the cases for :
use?
I know only of:
if(expression):
// do Something
endif;
while(expression):
// and others: `for` `foreach` etc.
endwhile;
Are there any other uses?
I'm wondering, what are the cases for :
use?
I know only of:
if(expression):
// do Something
endif;
while(expression):
// and others: `for` `foreach` etc.
endwhile;
Are there any other uses?
PHP offers an alternative syntax for some of its control structures; namely,
if
,while
,for
,foreach
, andswitch
. In each case, the basic form of the alternate syntax is to change the opening brace to a colon (:
) and the closing brace toendif;
,endwhile;
,endfor;
,endforeach;
, orendswitch;
, respectively.
http://us3.php.net/manual/en/control-structures.alternative-syntax.php
Ternary conditions: ($a == $b) ? true : false
.
Static calls inside a class: self::$a
.
Static methods calls: MyClass::MyMethod()
,
Static variables inside a class: MyClass::MyVariable
Parent methods calls: parent::hello()
switch
uses it for case 123:
and default:
.
::
is used to access static class members.
It is also used as part of the ternary operator "?:".