#23296 [Bgs->Opn]: Writing lines to file breaks new line separation
| From: | gfraley5 at earthlink dot net | Date: | Mon, 21 Apr 2003 14:45:55 +0000 |
| Subject: | #23296 [Bgs->Opn]: Writing lines to file breaks new line separation | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-37969@lists.php.net to get a copy of this message | ||
ID: 23296
User updated by: gfraley5 at earthlink dot net
Reported By: gfraley5 at earthlink dot net
-Status: Bogus
+Status: Open
Bug Type: Filesystem function related
-Operating System: win32,linux
+Operating System: WinXP, Win2k
PHP Version: 4.3.2RC1
New Comment:
My mistake. It is not working on Win32.
Previous Comments:
------------------------------------------------------------------------
[2003-04-21 09:37:17] sniper@php.net
Can not reproduce with latest stable CVS snapshot on linux.
------------------------------------------------------------------------
[2003-04-21 09:09:31] gfraley5 at earthlink dot net
This works in 4.3.1 and prior but does not work in 4.3.2RC's and
current CVS.
<?
$myArray[] = 'msgid'."\n";
$myArray[] = '1049987091'."\n";
$myArray[] = '1050930128'."\n";
$fp = fopen("problemFile.php",'w') or die("Unable to open file");
for ($i=0;$i<count($myArray);$i++) {
if ($i==0) $prefx = "<? Header(\"HTTP/1.0 403 Forbidden\");exit;
?>\n";
else $prefx = "";
fwrite($fp,$prefx.$myArray[$i]);
}
fclose($fp);
?>
The file looks like this, which is correct:
<? Header("HTTP/1.0 403 Forbidden");exit; ?>
msgid
1049987091
1050930128
However, under 4.3.2 the file looks like this:
<? Header("HTTP/1.0 403 Forbidden");exit; ?>
msgid1049987091
1050930128
If you modify the code to this, moving the header code to the array, it
works under 4.3.2:
<?
$myArray[] = "<? Header(\"HTTP/1.0 403 Forbidden\");exit; ?>\n";
$myArray[] = 'msgid'."\n";
$myArray[] = '1049987091'."\n";
$myArray[] = '1050930128'."\n";
$fp = fopen("problemFile.php",'w') or die("Unable to open file");
for ($i=0;$i<count($myArray);$i++) {
fwrite($fp,$myArray[$i]);
echo nl2br($myArray[$i]);
}
fclose($fp);
?>
The file is correct.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=23296&edit=1