Add ternary example (#24581)
This commit is contained in:
@ -90,9 +90,19 @@ For instance:
|
|||||||
|
|
||||||
## Ternary Operators
|
## Ternary Operators
|
||||||
|
|
||||||
Another important option to consider when using short If/Else statements is the ternary operator.
|
Another option to consider when using short If/Else statements is the ternary operator.
|
||||||
|
|
||||||
Also there is an alternative syntax for control structures
|
For instance:
|
||||||
|
|
||||||
|
```
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$var = (condition) ? (value if true) : (value if false);
|
||||||
|
```
|
||||||
|
|
||||||
|
## Alternative If/Else Syntax
|
||||||
|
|
||||||
|
There is also an alternative syntax for control structures
|
||||||
~~~~
|
~~~~
|
||||||
if (condition1):
|
if (condition1):
|
||||||
statement1;
|
statement1;
|
||||||
|
Reference in New Issue
Block a user