Introduction to PHP Tutorial:? (question mark) and: (colon)

Source: Internet
Author: User
Tags expression php tutorial

For example:

1
$shenhe = $val [' Available ']? Audited ": Not audited"

Often have just contacted a friend of Php asked me, PHP often see such as the code on the statement, question mark and colon what meaning, this statement is what meaning?

In fact, this is the abbreviation of an if statement, syntax in C language, conditional expression E1?e2:e3, if E1 is true (not 0), then the value of this expression is e2 value; If False, the value of the expression is E3. Equal to

1
2
3
4
5
6
$e = "" 02.if (E1) {
	$e =e2;
}
else{
	$e =e3;
}

Where E1, E2, E3 are expressions.



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.