Sometimes we may make some simple judgments in PHP... for example, to judge whether it is null. if it is blank, we usually write the following statements:
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 ();
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.