當我嘗試創建一個文件時,我無法換行/回車。 爲什麼它不起作用?我試着用:新行創建文件
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;
}
記事本不會向你顯示'\ n',這是一條看不見的指令。 – Prix
嘗試記事本++。它好多了。 –
如果您在使用* nix行結尾(「\ n」)的服務器上創建文件,但在Windows記事本中顯示需要窗口行尾的文件(「\ r \ n」),那麼它看起來好像是一行 - 無論是在Notepad ++中打開文件還是使用* nix行結尾讀取文件的編輯器,或者使用「\ r \ n」 –