在 PHP 中生成可下载的 CSV 时是否可以打印退格字符?
在 PHP 中生成输出时是否可以回显退格键?
情况:
if ($this->s) {
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=exportevent.csv");
header("Pragma: no-cache");
header("Expires: 0");
echo $this->s;
exit;
}
我在我的一个视图(Zend MVC)中编写了上述代码,在打印 $s 时,附加了许多(30)个空白行。我想退格这些行。有什么方法吗?
Is it possible to echo backspace while generating output in PHP?
Situation:
if ($this->s) {
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=exportevent.csv");
header("Pragma: no-cache");
header("Expires: 0");
echo $this->s;
exit;
}
I wrote the above code in one of my views (Zend MVC), while printing $s, a number of (30) blank rows are appended. I would like to backspace those rows. Is there any method for that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果必须删除回显点处的前导空白行,则要
删除回显之前的前导空格、换行符和回车符。
但您确实应该首先阻止生成这些行。
If you have to remove leading blank rows at the point of echo, then
to remove leading spaces, line feeds and carriage returns before the echo.
But you really should be preventing those lines from being generated in the first place.
你可以使用
you may use