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 ~
<Html>
Controller Method
<? Php
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 <expression 1>? <Expression 2>: <expression 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