我有以下测试脚本:
<?php
$myFile = "testFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = "Floppy Jalopy\n";
fwrite($fh, $stringData);
$stringData = "Pointy Pinto\n";
fwrite($fh, $stringData);
fclose($fh);
?>
但是,当运行并使用记事本打开时,数据以单行形式返回,没有中断,如下所示:
Floppy Jalopy(疯狂盒子)Pointy
Pinto(疯狂盒子)
我找不到“疯狂盒子”的合适字符,但它确实是一个疯狂的盒子。是什么赋予了!
最好使用PHP_EOL
。这是跨平台的,因此它会自动为 PHP 当前运行的平台选择正确的换行符。
$stringData = "Floppy Jalopy" . PHP_EOL;
PHP 常量 http://php.net/manual/en/reserved.constants.php
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)