如何在.txt文件中创建一个可工作的换行符


How do i make a working newline to .txt file?

有人能帮我在.txt中添加换行符吗?

$file = 'a.txt';
$current = file_get_contents($file);
$current .= "'.$test.''r'ntest";
file_put_contents($file, $current);

那些不适合我

'n
'r'n
$n = "" . PHP_EOL;
$n = "
";
file_put_contents("test.txt","test1'ntest2'ntest3");

你可以试试这个:

        $myfile = fopen("yourtxt file", "w");
        fwrite($myfile, "some text"."'n");
        fclose($myfile);

根据您的代码,尝试以下操作:

$test = 'some content';
$file = 'a.txt';
$current = file_get_contents($file);
$current .= $test."'ntest";
file_put_contents($file, $current);

您应该使用"'n"''n'不工作。