在 symfony2 中渲染数据时删除第一行
Remove first line while rendering data in symfony2
我目前正在研究 symfony2 框架。我想要 twig 文件在一个文件中呈现的 html 数据。
我的代码:
$myfile = fopen("somefile.html", "w");
$data = $this->render("somefile.html.twig");
fwrite($myfile, $data);
这很好用,但除了 html 数据外,我还得到以下行
"HTTP/1.0 200 OK
缓存控制:无缓存
日期: 2015 年 6 月 2 日,星期二 07:50:16 GMT
作为凝视线,我想删除它们是否可以通过 symfony 或我使用正则表达式?
尝试使用 renderView() 而不是 render()。
$myfile = fopen("somefile.html", "w");
$data = $this->renderView("somefile.html.twig");
fwrite($myfile, $data);
尝试添加 ->getContent() 函数:
$myfile = fopen("somefile.html", "w");
$data = $this->render("somefile.html.twig");
fwrite($myfile, $data->getContent());
我目前正在研究 symfony2 框架。我想要 twig 文件在一个文件中呈现的 html 数据。
我的代码:
$myfile = fopen("somefile.html", "w");
$data = $this->render("somefile.html.twig");
fwrite($myfile, $data);
这很好用,但除了 html 数据外,我还得到以下行
"HTTP/1.0 200 OK
缓存控制:无缓存
日期: 2015 年 6 月 2 日,星期二 07:50:16 GMT
作为凝视线,我想删除它们是否可以通过 symfony 或我使用正则表达式?
尝试使用 renderView() 而不是 render()。
$myfile = fopen("somefile.html", "w");
$data = $this->renderView("somefile.html.twig");
fwrite($myfile, $data);
尝试添加 ->getContent() 函数:
$myfile = fopen("somefile.html", "w");
$data = $this->render("somefile.html.twig");
fwrite($myfile, $data->getContent());