Skip to content

Instantly share code, notes, and snippets.

@flaviors200
Last active June 4, 2019 18:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flaviors200/d5405a22683944970f5d43f61ce8130e to your computer and use it in GitHub Desktop.
Save flaviors200/d5405a22683944970f5d43f61ce8130e to your computer and use it in GitHub Desktop.
Conditional statement: the ternary operator
<?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