Php smarty获取字符串替换
当使用$smarty->fetch时,它将模板拉入变量。有没有办法对该变量进行预解析字符串操作 例如: PHP: template.tplPhp smarty获取字符串替换,php,smarty,Php,Smarty,当使用$smarty->fetch时,它将模板拉入变量。有没有办法对该变量进行预解析字符串操作 例如: PHP: template.tpl {include file='incl.tpl'} 理想的结果是模板变成: {include file='../another_dir/incl.tpl'} 您必须先编辑模板。然后您可以使用fetch 大概是这样的: $template = file_get_contents('template.tpl'); $template = str_replac
{include file='incl.tpl'}
理想的结果是模板变成:
{include file='../another_dir/incl.tpl'}
您必须先编辑模板。然后您可以使用fetch 大概是这样的:
$template = file_get_contents('template.tpl');
$template = str_replace("{include file='../another_dir", "{include file='", $template);
$variable = $smarty->fetch('string:' . $template);
聪明的
$template = file_get_contents('template.tpl');
$template = str_replace("{include file='../another_dir", "{include file='", $template);
$variable = $smarty->fetch('string:' . $template);