#41609 [Opn->Fbk]: file_put_contents() injects \r
| From: | tony2001@php.net | Date: | Wed, 06 Jun 2007 08:38:47 +0000 |
| Subject: | #41609 [Opn->Fbk]: file_put_contents() injects \r | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-113451@lists.php.net to get a copy of this message | ||
ID: 41609
Updated by: tony2001@php.net
Reported By: zoe at uk dot ibm dot com
-Status: Open
+Status: Feedback
Bug Type: Filesystem function related
Operating System: Windows XP
PHP Version: 6CVS-2007-06-06 (snap)
New Comment:
Could you plz try the same on Linux?
I can't replicate it there.
Previous Comments:
------------------------------------------------------------------------
[2007-06-06 08:08:15] zoe at uk dot ibm dot com
Description:
------------
A file created on Windows using file_put_contents in PHP6 has different
contents if unicode.semantics=1 is used.
The files (data.tmp) created by the test case below have different
contents, from "od -x" it looks to me as though an additional \r is
inserted in the file before the \n.
Reproduce code:
---------------
<?php
$file_path = dirname(__FILE__);
$buffer = "text\nline of text\n";
file_put_contents( $file_path."/data.tmp", (binary)$buffer);
$fp = fopen($file_path."/data.tmp", "r");
var_dump( file_get_contents($file_path."/data.tmp") );
fclose($fp);
$fp = fopen($file_path."/data.tmp", "r");
var_dump( fgets($fp) );
fclose($fp);
$fp = fopen($file_path."/data.tmp", "rb");
var_dump( fgets($fp) );
fclose($fp);
$fp = fopen($file_path."/data.tmp", "rt");
var_dump( fgets($fp) );
fclose($fp);
?>
Expected result:
----------------
string(18) "text
line of text
"
string(5) "text
"
string(5) "text
"
string(5) "text
"
Actual result:
--------------
string(20) "text
line of text
"
string(6) "text
"
string(6) "text
"
unicode(5) "text
"
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41609&edit=1