gpt4 book ai didi

php - 在 PHP 中写入文本文件时换行不起作用

转载 作者:IT王子 更新时间:2023-10-29 01:14:35 27 4
gpt4 key购买 nike

我有以下测试脚本:

<?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);

?>

但是,当运行并打开 usign Notepad 时,数据在一行中返回,没有中断:

Floppy Jalopy(crazy box)Pointy Pinto(crazy box)

我找不到适合“疯狂盒子”的角色,但它是一个非常疯狂的盒子。什么给了!

最佳答案

最好使用PHP_EOL。这是跨平台的,因此它会自动为 PHP 当前运行的平台选择正确的换行符。

$stringData = "Floppy Jalopy" . PHP_EOL;

PHP Constants

关于php - 在 PHP 中写入文本文件时换行不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4195986/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com