tp5.1 模板中include使用变量修改方法
\thinkphp\library\think\Template.php ,找到538行,插入以下代码,
// 分析模板文件名并读取内容 之前
// 以$开头字符串转换成模板变量
$file = explode('/',$file);
foreach ($file as $key => $value) {
if (0 === strpos($value, '$')) {
$value = $this->get(substr($value, 1));
}
$file[$key] = $value;
}
$file = implode("/", $file);
如此:模板中即可使用来引入模板了
{include file="public/$table" /}