Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/52.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用php编写文本文件时出现的问题_Php_Yii_Php 5.3_Fwrite_Urldecode - Fatal编程技术网

用php编写文本文件时出现的问题

用php编写文本文件时出现的问题,php,yii,php-5.3,fwrite,urldecode,Php,Yii,Php 5.3,Fwrite,Urldecode,我使用urldecode数据将内容写入文本文件,但在该文件中,所有内容都显示在windows记事本中(预期未对齐)(在windows写字板中显示正确),并且在Ubuntu中打开时,内容也显示正确(我的内容也有输入键和空格以及一些特殊字符) 因为我做了快速修复 $content = str_replace("\n","\r\n",$content); 但是我想知道还有其他方法可以做到这一点。如果您使用Linux创建该文件,您应该手动添加该文件。如果您使用Windows,您可以尝试使用str\u

我使用urldecode数据将内容写入文本文件,但在该文件中,所有内容都显示在windows记事本中(预期未对齐)(在windows写字板中显示正确),并且在Ubuntu中打开时,内容也显示正确(我的内容也有输入键和空格以及一些特殊字符)

因为我做了快速修复

$content = str_replace("\n","\r\n",$content);

但是我想知道还有其他方法可以做到这一点。

如果您使用Linux创建该文件,您应该手动添加该文件。如果您使用Windows,您可以尝试使用str\u replace(“\n”,PHP\u EOL,$content)代替


我不明白你为什么要做URL解码。如果你的数据是utf-8格式的,也许你应该使用utf8_decode之类的东西。

因为空格被%20取代了为什么你要使用urlencode呢?Robert urlencode数据来自Iphone和Ipad的后端,在这里,我们使用yii来处理数据,并执行一些其他操作。因此,如果单词被分割,您可能会遇到行尾问题,这在Unix系统和Windows中是不同的,请尝试执行类似于
stru\u replace(“\n”、“\r\n”、$content)的操作
替换unix EOL for windows EOL。服务器正在接受json编码格式的数据,从ios前端他们将数据发送到urlencode格式,我不熟悉ios开发,服务器端获取的数据包含空格、回车和特殊字符
$content = str_replace("\n","\r\n",$content);