gpt4 book ai didi

php - 在 TWIG 中使用 PHP 函数?

转载 作者:IT王子 更新时间:2023-10-28 23:52:22 25 4
gpt4 key购买 nike

在 PHP 模板中我可以使用 php 函数,例如:

foreach ($users as $user){
echo someFunction($user->getName());
}

如何在 TWIG 中制作它?

{% for user in users %}
* {{ user.name }}
{% else %}
No user have been found.
{% endfor %}

我如何实现这一目标?

最佳答案

你需要的是functionsfilters .您可以使用示例轻松添加这些内容。

关于php - 在 TWIG 中使用 PHP 函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8180585/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com