Home  >  Article  >  Backend Development  >  Ternary operator in TP3.2

Ternary operator in TP3.2

不言
不言Original
2018-04-21 13:30:172999browse

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>
  1. ##{<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>

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

Note: Dot syntax is not currently supported in the ternary operator.

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;

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn