Sometimes we may make some simple judgments in PHP, such as determining whether it is null or not. If it is blank, fill in the values.
Sometimes we may make some simple judgments in PHP, such as determining whether it is null or not. If it is blank, fill in the values.
Generally, we will write as follows:
The Code is as follows:
If ($ _ GET ['time'] = null)
{
$ Time = time ();
}
Else
{
$ Time = $ _ GET ['time'];
}
Echo $ time;
// If GET has time, the variable time is included. If not, the current time () time is included.
?>
If you only make a simple judgment, it will be too troublesome to write as above, and the efficiency is not high!
You can change it to the triplicate method:
The Code is as follows:
$ Time = ($ _ GET ['time'] = null )? (Time (): ($ _ GET ['time']);
Echo $ time;
?>
Concise!
I would like to explain the meaning of a trigger.
If the sentence in the first parentheses () is true, the question mark is executed? If the content of the first parentheses () is not true, the question mark is executed? Content of the second bracket ()
The Code is as follows:
$ A = 5; // define variable a = 5
$ B = 3; // define variable B = 5
$ C = ($ a = $ B )? ("Yes"): ("no ");
// If a = B, c = yes; a is not equal to B, c = no
?>
There is also a simplified
The Code is as follows:
$ Bool = true;
If ($ bool)
{
SetValueFun ();
}
Can be simplified
The Code is as follows:
$ Bool & setValueFun ();