...
Code Block |
---|
// Short description on what is being achieved when the if statement is true if ( $foo > 10 && $bar == "X" && ( $baz == "Y" || $qux == "Z" ), // description of what the statement is doing do ( Statement 1 ), // else, description of what the statement is doing Statement 2 ) |
Layout for switch()
Simple
For simple switch statements we recommend the following layout:
Code Block |
---|
switch( [ condition expression 1, Statement 1 ], [ condition expression 2, Statement 2 ], // default _NULL ) switch( [ $foo > 100, $x = "HIGH" ], [ $bar > 50, $x = "MEDIUM" ], // default $x = "LOW", ) |
Advanced
For switch statements that perform more advanced activities we recommend the following layout:
Code Block |
---|
switch (
// description of what the statement is doing
[$foo == 100,
$x = "HIGH"
],
// description of what the statement is doing
[$bar == 50,
do (
$x = "Medium",
$x = toUpper($x)
)
]
// default
do (
$x = "LOW"
)
) |
...