【发布时间】:2019-10-23 23:09:25
【问题描述】:
我正在尝试在 smarty 中做一个 regex_replace,我已经绑定了以下内容,但它会打印变量名,不返回变量值。
如何替换为$another?
尝试
{$title|regex_replace:"/apple/":"{$another}"}
【问题讨论】:
标签: php regex string replace smarty3
我正在尝试在 smarty 中做一个 regex_replace,我已经绑定了以下内容,但它会打印变量名,不返回变量值。
如何替换为$another?
{$title|regex_replace:"/apple/":"{$another}"}
【问题讨论】:
标签: php regex string replace smarty3
我的猜测是,我们可能不想拥有{$another},我们可以试试:
{assign var="p_open" value="<p class='bla'>"}
{assign var="p_text" value=$another.xyz}
{assign var="p_close" value="</p>"}
{assign var="replace" value=$p_open$p_text$p_close}
{$title|regex_replace:"/(apple)/":$replace}
【讨论】:
{$another}
'},怎么会如果有标签,类,可以使用 var 吗?正确的验证。您需要在 replace var 上添加和关闭“(引号)标记才能在这种情况下正常工作。
{assign var="p_open" value="<p class='bla'>"}
{assign var="p_text" value=$another.xyz}
{assign var="p_close" value="</p>"}
{assign var="replace" value="$p_open$p_text$p_close"}
{$title|regex_replace:"/(apple)/":$replace}
【讨论】: