#23296 [Bgs->Opn]: Writing lines to file breaks new line separation
| From: | gfraley5 at earthlink dot net | Date: | Mon, 21 Apr 2003 15:27:04 +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-37986@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: WinXP, Win2k
PHP Version: 4.3.2RC1
New Comment:
I just pulled the latest win32 package and it does not work on XP or
win2k. It fails 100% of the time. It works 100% of the time when I
reinstall 4.3.1. Here is the link I am pulling the latest snap from
http://snaps.php.net/win32/php4-win32-STABLE-200304210830.zip.
If this
is correct, then the code does not work. Also, as to the \n or \r\n.
\n is working 100% of the time, on Windows, on php4.3.1 and prior. The
fact that I can go on 2 different versions of windows in 2 different
locations and reproduce this validates the test, imo. The win2k
version I am using is 5.00.2195.
Previous Comments:
------------------------------------------------------------------------
[2003-04-21 09:54:23] sniper@php.net
Can not reproduce in win2k using latest STABLE snapshot.
(and windows expects \r\n as line-end)
------------------------------------------------------------------------
[2003-04-21 09:45:55] gfraley5 at earthlink dot net
My mistake. It is not working on Win32.
------------------------------------------------------------------------
[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