Home > Article > Backend Development > Ternary operator in TP3.2
The content of this article is about the ternary operator in TP3.2. It has certain reference value. Now I share it with everyone. Friends in need can refer to it.
Read the manual first ,
templates can support ternary operators, for example:
<br>
##{<span style="margin:0px;padding:0px;"></span>$status<span style="margin:0px;padding:0px;"></span>?<span style="margin:0px;padding:0px;"></span>'Normal'<span style="margin:0px;padding:0px;"></span>:<span style="margin:0px;padding:0px;"></span>'Error'<span style="margin:0px;padding:0px;"></span>}<span style="margin:0px;padding:0px;"></span>
{<span style="margin:0px;padding:0px;"></span>$info<span style="margin:0px;padding:0px;"></span>[<span style="margin:0px;padding:0px;"></span>'status'<span style="margin:0px;padding:0px;"></span>]?<span style="margin:0px;padding:0px;"></span>$info<span style="margin:0px;padding:0px;"></span>[<span style="margin:0px;padding:0px;"></span>'msg'<span style="margin:0px;padding:0px;"></span>]:<span style="margin:0px;padding:0px;"></span>$info<span style="margin:0px;padding:0px;"></span>[<span style="margin:0px;padding:0px;"></span>'error'<span style="margin:0px;padding:0px;"> </span>]}<span style="margin:0px;padding:0px;"></span>
What does that mean? That is to say, dot syntax is not supported. I took a detour when writing like this before. For example: {$vo.email}?1:0; It is wrong to write like this. You should change it to {$vo ['email']}?1:0;Note: Dot syntax is not currently supported in the ternary operator.
<br>
Related recommendations:PHP Get a certain period of the current day
The above is the detailed content of Ternary operator in TP3.2. For more information, please follow other related articles on the PHP Chinese website!