Add a trielement operator to the array output by the template to judge. array operator _ PHP Tutorial

Source: Internet
Author: User
The trielement operator is added to the array output by the template. The trielement operator is added to the array output by the template to determine. the array operator provides an easy-to-use judgment method. it is quite convenient to add the trielement operator to the array output by the template. The trielement operator is added to the array output by the template. the array operator

It is convenient to get a good method of judgment by adding a ternary operator to the array output by the template. Of course, you can also use Ajax ~

      No titleWhat is my slogan? --> <{$ Data ['user']? 'No problem. ': Wow is too big.}>
// Reminder: the ternary operator cannot accept symbols. Otherwise, an error is returned! <{$ Data ['email ']}>
<{$ Data ['address']}>
<{$ Data ['num'] + 10}>

Controller method

 Namespace Home \ Controller;
Use Think \ Controller;
Public function index () {$ data ['user'] = 'You Love Me '; $ data ['email'] = 'integer @ gmail.cn '; $ data ['address'] = 'Mainland China'; $ data ['num'] = '21'; // $ this-> assign ('num', 10 ); $ this-> assign ('data', $ data); $ this-> display ();}


C # The three operators are the three operators. The estimation is conditional. how is the calculation performed?

Ternary operator? :
For example, I = 2> 3? 0: 1
2 is greater than 3. if yes, I = 0; otherwise, I = 1.

In C #, the ternary operator is () A = B? : C! = D <>

Select B
Three-object operator <表达式1> ? <表达式2> : <表达式3> ;, Which belongs to relational operators,
It is often used for relational comparison. it is mainly used to compare the state of a link in only two cases (greater than or not greater than, true or false)
Evaluate the value of expression 1 first. if true, execute expression 2 and return the result of expression 2. if expression 1 is false, execute expression 3 and return the result of Expression 3.
For example, the following expression:
A> 0? A ++ :( a = 1)
When a> 0 is true, execute a ++. The value of the entire expression is equal to the value of expression a ++,
When a> 0 is false, run a = 1. the value of the entire expression is equal to the value of expression a = 1.
Reference: zhidao.baidu.com/question/342133017.html

Explain to get a good method of judgment. it is very convenient to add a ternary operator to the array output by the template ....

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.