In general we will write this:
Copy the Code code as follows:
if ($_get[' time ']==null)
{
$time = time ();
}
Else
{
$time = $_get[' time '];
}
Echo $time;
If get has time this value is brought into the variable.
?>
If only simple judgment, according to the above writing is too troublesome, and the performance is not high!
Can be changed to use ternary one-time:
Copy the Code code as follows:
$time = ($_get[' time ']==null)? (Time ()): ($_get[' time ');
Echo $time;
?>
Much more concise!
Probably explain the meaning of ternary one-time
If the sentence inside the first parenthesis () is set, the question mark is executed? The contents of the first parenthesis (), if not, execute the question mark? The contents of the second parenthesis ()
Copy the Code code as follows:
$a = 5; Defining Variables A=5
$b = 3; Defining Variables B=5
$c = ($a = = $b)? ("Yes"): ("no");
If A=b,c is =yes; A is not equal to B,c =no
?>
There is also a simplified
Copy the Code code as follows:
$bool = true;
if ($bool)
{
Setvaluefun ();
}
can be simplified into
Copy the Code code as follows:
$bool && Setvaluefun ();
The above describes what else is the meaning of the PHP IF else simplification/ternary one-time use, including what else is the meaning of the content, I hope to be interested in PHP tutorial friends helpful.