在PHP中写入文本文件时换行不起作用 [英] Line break not working when writing to text file in PHP

查看:288
本文介绍了在PHP中写入文本文件时换行不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下测试脚本:

<?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记事本时,数据将以单行形式返回,且不会出现以下中断:

when run however and opened usign Notepad, the data is returned in a single line without breaks as:

软盘Jalopy(疯狂的盒子)尖 平托(疯狂的盒子)

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

在这里我找不到适合疯狂盒子"的角色,但它确实是一个疯狂的盒子.给予什么!

where i cant find the appropriate character for 'crazy box' but its a REALLY crazy box. WHAT GIVES!

推荐答案

如果要在Windows记事本中打开文件,则必须使用Windows换行符:\r\n

If you want to open the file in Windows notepad, you must use Windows line breaks: \r\n

这篇关于在PHP中写入文本文件时换行不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆