可以在 codeigniter force_download 函数中创建多行文本文件吗?
possible to create a multiline text file in codeigniter force_download function?
我已经用'\n'和'\r'和'\r\n'而不是'<br/>'
试过这段代码。
但它按原样显示,而不是将其转换为新行。
有人帮我解决这个问题吗?
$this->load->helper('download');
$data = 'Here is some text!';
$data .= '<br/> Here is some text!';
$name = 'mytext.txt';
force_download($name, $data,TRUE);
您的代码应该是
$this->load->helper('download');
$data = "Here is some text! \n";
$data .= 'Here is some more text in new line!';
$name = 'mytext.txt';
force_download($name, $data,TRUE);
单引号中的 '\n'
是文字 \n
.
双引号中的 "\n"
被解释为 line break
.
试试这个:
$this->load->helper('download');
$data = "Here is some text! \n";
$data .= 'Here is some text!';
$name = 'mytext.txt';
force_download($name, $data,TRUE);
我已经用'\n'和'\r'和'\r\n'而不是'<br/>'
试过这段代码。
但它按原样显示,而不是将其转换为新行。
有人帮我解决这个问题吗?
$this->load->helper('download');
$data = 'Here is some text!';
$data .= '<br/> Here is some text!';
$name = 'mytext.txt';
force_download($name, $data,TRUE);
您的代码应该是
$this->load->helper('download');
$data = "Here is some text! \n";
$data .= 'Here is some more text in new line!';
$name = 'mytext.txt';
force_download($name, $data,TRUE);
单引号中的 '\n'
是文字 \n
.
"\n"
被解释为 line break
.
试试这个:
$this->load->helper('download');
$data = "Here is some text! \n";
$data .= 'Here is some text!';
$name = 'mytext.txt';
force_download($name, $data,TRUE);