Last active
January 27, 2020 18:51
-
-
Save Yigaue/b6fee9cca4248c593f37966ff6f9943b to your computer and use it in GitHub Desktop.
Ternary operators collection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
| The commented code shows the full code of the ternary equiv. | |
*/ | |
// if ($age = 20 < 22) | |
// { | |
// echo "You are young"; | |
// } | |
// else echo "You are growing old"; | |
// In ternary | |
echo $message = ($age = 20 > 21) ? 'you are young' : 'you are growing old'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment