PHPIFELSE simplified/three-element one-time usage _ PHP Tutorial

Source: Internet
Author: User
PHPIFELSE simplifies the use of the trigger once. Generally, we write the following code :? If ($ _ GET [time] null) {$ timetime ();} else {$ time $ _ GET [time];} echo $ time; if GET has the value of time, the variable is generally written 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 ();

The pipeline code is as follows :? If ($ _ GET ['Time'] = null) {$ time = time ();} else {$ time = $ _ GET ['Time'];} echo $ time; // if GET has time, the variable is included...

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.