当我尝试创建文件时,我无法进行换行/回车。为什么它不起作用?我试过:
PHP_EOL
\n
但是当我用记事本查看它时,它并没有创建新行
<?php
$file = 'myText.txt';
$id = '1'.$file;
//explode($delimiter, $id);
$content = "<PMTags1.0 win>". PHP_EOL;
$content .= . PHP_EOL;
while($row = mysqli_fetch_array($result))
{
$content .= "<@win:><\<>win>". $row['kategoria'] . PHP_EOL;
$content .= "<@tekst:><\<>tekst><$>";
$content .= $row['text'];
$content .= $gcid.$row['id'].'/'. PHP_EOL;
}
utf8_encode($content);
echo $content;
//Stworzenie pliku
$fp = fopen(trim(trim($id)),"wb");
fwrite($fp,$content);
fwrite($fp, pack("CCC",0xef,0xbb,0xbf));
fopen(trim(trim($id)),"r");
fclose($fp);
//End 4
//5 - Otwarcie pliku
if (file_exists(trim($id))) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename(trim($id)));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize(trim($id)));
ob_clean();
flush();
readfile(trim($id));
exit;
}