使用 e/ 修饰符替代函数 preg_replace
Alternative for function preg_replace with e/ modifier
任何人都知道如何使用 preg_replace 和 /e 修饰符更改此函数。调试时出现奇怪的错误,因为 /e modifier.Seems 已贬值。
$globCont = preg_replace("/{(\w*)}/e", '$this->TemplateGlobals[""]', $content);
使用匿名函数:
$globCont = preg_replace_callback("/{(\w*)}/",
function($m) {
return $this->TemplateGlobals[$m[1]];
}, $content);
任何人都知道如何使用 preg_replace 和 /e 修饰符更改此函数。调试时出现奇怪的错误,因为 /e modifier.Seems 已贬值。
$globCont = preg_replace("/{(\w*)}/e", '$this->TemplateGlobals[""]', $content);
使用匿名函数:
$globCont = preg_replace_callback("/{(\w*)}/",
function($m) {
return $this->TemplateGlobals[$m[1]];
}, $content);