我试图将一个视图发送到另一个视图,然后呈现所有视图。 但我不能
$app->get('/',function () use ($app) {
$data = array(
'content' => $app->view->fetch('home.php')
);
$app->render('layout.php', $data);
});
如何使用 Slim Framework 执行此操作?
这样的东西应该在最新版本(2.4.0)的Slim框架中工作:
$app->get('/',function () use ($app) {
$content = $app->view->fetch('home.php');
$app->render('layout.php', array('content' => $content));
});
在布局中.php
<html>
<?php echo $content; ?>
</html>
https://github.com/codeguy/Slim/releases"查看模板数据"下查看此处