【发布时间】:2018-04-18 08:16:37
【问题描述】:
我正在使用Slim 3 构建一个应用程序。
在某条路线中,我通过include_once 包含模板的标题(slim/php-view 2.2),并且有一些我需要发送到模板的变量在标题中使用。
有没有办法做到这一点?
我的路线:
$app->get('/', function ( $request, $response) {
// some code here...
$somedata = ' this is just a test';
return $this->renderer->render($response, "/home.phtml",[
'somedata' => $somedata,
]);
})
目标模板(home.phtml):
<?php include_once('myheader.php'); ?>
<h1>This is my template</h1>
<p> I need to use this variable <?=$somedata?>
in the included myheader.php file</p>
【问题讨论】:
标签: php templates routes slim slim-3