Last active
June 4, 2019 18:04
-
-
Save flaviors200/d5405a22683944970f5d43f61ce8130e to your computer and use it in GitHub Desktop.
Conditional statement: the ternary operator
This file contains 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 | |
$year = 2020; | |
echo ($year % 4 == 0) ? "$year è un'anno bisestile" : "$year non è un'anno bisestile"; | |
// Output: 2020 è un'anno bisestile | |
/******* Forma normale ********/ | |
/* | |
/* if ($year % 4 == 0) { | |
/* echo "$year è un'anno bisestile"; | |
/* } else { | |
/* echo "$year non è un'anno bisestile"; | |
/* } | |
/* | |
/*****************************/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment