Twig模板引擎显示奇怪的信息

时间:2018-01-20 13:56:10

标签: php twig

我是Twig的第一天用户,我有一些奇怪的引擎行为。 我将一些信息推到我的观点:

class MainController extends Controller {


public function actionIndex()
{

    $template = self::$twig->loadTemplate('index.php');
    $title = 'CRUD интерфейс';
    $projects = MainList::showAll();
    $workers = CompanyWorker::showAll();
    $roles = Role::showAll();
    $namesOfProjects = Project::showAll();
    echo $template->render(array(
        'title' => $title,
        'projects' => $projects,
        'workers' => $workers,
        'roles' => $roles,
        'namesOfProjects' => $namesOfProjects
    ));
}

}

最后我有一个很好的结果但是在HTML文件的最后,twig显示了我的控制器对象。它为什么会发生?

enter image description here

这是我的Twig初始化:     抽象类控制器{

public $loader;
static $twig;


function __construct()

{
    $this->loader = new Twig_Loader_Filesystem('views');
    //$twig = new Twig_Environment($loader, array('cache' => 'cache'));
    self::$twig = new Twig_Environment($this->loader);
}

1 个答案:

答案 0 :(得分:0)

我是盲人8 [。我真的很想念' print_r'闪光功能