Update index.md (#26333)

Added and example of ternary syntax.
This commit is contained in:
pirland
2018-12-13 02:31:49 -06:00
committed by Randell Dawson
parent c2de333137
commit f9e2fdb55f

View File

@ -90,26 +90,24 @@ For instance:
## Ternary Operators ## Ternary Operators
Another option to consider when using short If/Else statements is the ternary operator. Another important option to consider when using short If/Else statements is the ternary operator.
For instance: ```php
$statement=(condition1 ? "condition1 is true" : "condition1 is false");
```
<?php
$var = (condition) ? (value if true) : (value if false);
``` ```
## Alternative If/Else Syntax ## Alternative If/Else Syntax
There is also an alternative syntax for control structures There is also an alternative syntax for control structures
~~~~
```php
if (condition1): if (condition1):
statement1; statement1;
endif; endif;
else else
statement5; statement5;
~~~~ ```
For more information check out the following link: For more information check out the following link:
<a href='http://php.net/manual/en/control-structures.alternative-syntax.php' target='_blank' rel='nofollow'>PHP Alternative syntax for control structures</a> <a href='http://php.net/manual/en/control-structures.alternative-syntax.php' target='_blank' rel='nofollow'>PHP Alternative syntax for control structures</a>