Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Smarty3 是否有像Twig一样工作的“in”运算符:
{% if option in [1, 2, 3] %}
?
是和不是。Smarty 对此没有自己的语法,但你可以这样做:
{if in_array("foo", ["bar", "foo"])}
我个人觉得 in 关键字令人困惑。PHP 本身并不知道。Javascript 是唯一与模板开发人员相关的其他编程语言,它将 in 关键字视为array_key_exists()而不是in_array(). 不确定我是否希望给定的模板引擎做一些不同的事情……</p>
array_key_exists()
in_array()