#23296 [Opn->Bgs]: Writing lines to file breaks new line separation

From: Date: Mon, 21 Apr 2003 14:54:25 +0000
Subject: #23296 [Opn->Bgs]: Writing lines to file breaks new line separation
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-37971@lists.php.net to get a copy of this message
ID: 23296 Updated by: sniper@php.net Reported By: gfraley5 at earthlink dot net -Status: Open +Status: Bogus Bug Type: Filesystem function related Operating System: WinXP, Win2k PHP Version: 4.3.2RC1 New Comment: Can not reproduce in win2k using latest STABLE snapshot. (and windows expects \r\n as line-end) Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#37971) next »