Removing the first line when rendering data in symfony2

I am currently working on the concept of symfony2. I want the html data to display the twig file in one file.

My code is:

$myfile = fopen("somefile.html", "w"); $data = $this->render("somefile.html.twig"); fwrite($myfile, $data); 

This works fine, but in addition to the html data, I get the following line: "HTTP / 1.0 200 OK
Cache-control: no-cache
Date: Tue, 02 Jun 2015 07:50:16 GMT "

like looking lines that I want to delete, is this possible through symfony or am I using regex?

+6
source share
1 answer

Try using renderView () instead of render ().

 $myfile = fopen("somefile.html", "w"); $data = $this->renderView("somefile.html.twig"); fwrite($myfile, $data); 
+3
source

Source: https://habr.com/ru/post/988377/


All Articles