响应 Symfony2 中生成的 CSV 的额外行
Extra line in response of generated CSV in Symfony2
我有一个使用 Response 生成 CSV 文件的代码,但我得到了一个我想删除的额外数据,这个额外数据是:
此时我不确定是 PHP 还是服务器。
有人知道为什么会遇到这个问题吗?
我的代码:
$rows = array();
foreach ($entities as $entity) {
$data = ........ // here is the array //
$rows[] = implode(';', $data);
}
$content = implode("\n", $rows);
$response = new Response($content);
$response->headers->set('Content-Type', 'text/csv');
$response->headers->set('Content-Disposition', $filename);
return $response;
文件显示如下:
31/03/2021;1;03;2183752;06140809820010;信条,S.A。 DE C.V.;0.00;0.00;0.00;3.78;0.00;0.00;0.49;4.27;3
31/03/2021;1;03;2183851;06140809820010;信条,S.A。 DE C.V.;0.00;0.00;0.00;70.89;0.00;0.00;9.22;80.11;3
31/03/2021;1;03;2325856;06140809820010;信条,S.A。 DE C.V.;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;3
31/03/2021;1;03;2325857;06140809820010;信条,S.A。 DE C.V.;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;3
奇怪的是,我在配置文件中发现了这一行 app.php
/* START HOST DEBUG CODE */
class LastSay
{
public function __construct()
{
$ipList = array('67.23.232.183','72.29.91.30', '67.23.232.178', '2607:fcd8:a:5:ce9b:a1b2:b2f6:6b7c');
if( in_array( $_SERVER['REMOTE_ADDR'] , $ipList ) )
{
file_put_contents("hdpid.txt", getmypid());
if(!isset($_GET['fast']))
sleep(10);
}
}
public function __destruct()
{
echo "<!-- STRACE__TIMER__BREAK -->";
}
}
$varNameDoesntMatter = new LastSay();
/* END HOST DEBUG CODE */
我刚刚删除了它。
我有一个使用 Response 生成 CSV 文件的代码,但我得到了一个我想删除的额外数据,这个额外数据是: 此时我不确定是 PHP 还是服务器。 有人知道为什么会遇到这个问题吗?
我的代码:
$rows = array();
foreach ($entities as $entity) {
$data = ........ // here is the array //
$rows[] = implode(';', $data);
}
$content = implode("\n", $rows);
$response = new Response($content);
$response->headers->set('Content-Type', 'text/csv');
$response->headers->set('Content-Disposition', $filename);
return $response;
文件显示如下:
31/03/2021;1;03;2183752;06140809820010;信条,S.A。 DE C.V.;0.00;0.00;0.00;3.78;0.00;0.00;0.49;4.27;3 31/03/2021;1;03;2183851;06140809820010;信条,S.A。 DE C.V.;0.00;0.00;0.00;70.89;0.00;0.00;9.22;80.11;3 31/03/2021;1;03;2325856;06140809820010;信条,S.A。 DE C.V.;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;3 31/03/2021;1;03;2325857;06140809820010;信条,S.A。 DE C.V.;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;3
奇怪的是,我在配置文件中发现了这一行 app.php
/* START HOST DEBUG CODE */
class LastSay
{
public function __construct()
{
$ipList = array('67.23.232.183','72.29.91.30', '67.23.232.178', '2607:fcd8:a:5:ce9b:a1b2:b2f6:6b7c');
if( in_array( $_SERVER['REMOTE_ADDR'] , $ipList ) )
{
file_put_contents("hdpid.txt", getmypid());
if(!isset($_GET['fast']))
sleep(10);
}
}
public function __destruct()
{
echo "<!-- STRACE__TIMER__BREAK -->";
}
}
$varNameDoesntMatter = new LastSay();
/* END HOST DEBUG CODE */
我刚刚删除了它。