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 ....