#23296 [NEW]: Writing lines to file breaks new line separation

From: Date: Mon, 21 Apr 2003 14:09:31 +0000
Subject: #23296 [NEW]: Writing lines to file breaks new line separation
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-37942@lists.php.net to get a copy of this message
From: gfraley5 at earthlink dot net Operating system: win32,linux PHP version: 4.3.2RC1 PHP Bug Type: Filesystem function related Bug description: Writing lines to file breaks new line separation 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 bug report at http://bugs.php.net/?id=23296&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=23296&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=23296&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=23296&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=23296&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=23296&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=23296&r=support Expected behavior: http://bugs.php.net/fix.php?id=23296&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=23296&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=23296&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=23296&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=23296&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=23296&r=dst IIS Stability: http://bugs.php.net/fix.php?id=23296&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=23296&r=gnused

« previous php.bugs (#37942) next »