#23406 [Fbk->Opn]: \r\n not functioning the same from 4.3.1 and prior

From: Date: Tue, 29 Apr 2003 14:27:02 +0000
Subject: #23406 [Fbk->Opn]: \r\n not functioning the same from 4.3.1 and prior
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-38718@lists.php.net to get a copy of this message
ID: 23406 User updated by: gfraley5 at earthlink dot net Reported By: gfraley5 at earthlink dot net -Status: Feedback +Status: Open Bug Type: Filesystem function related Operating System: Win98SE,WinXP,Win2K PHP Version: 4.3.2RC2 New Comment: Adding the 'wb' corrects the problem. But, and here is the most important issue, the behavior HAS changed from 4.3.1 and prior to 4.3.2 and it definitely breaks and renders useless the file that it writes out, based on how the input routines then read that file in 4.3.1 and prior. If you use \n instead of \r\n you have the same issue except the you don't get the line feed extra line. I did check the actual line endings and they are different and the byte count is different also. My ini settings have not changed. Can you explain why this change in behaviour has been made? Thanks. Previous Comments: ------------------------------------------------------------------------ [2003-04-29 09:12:05] wez@php.net fopen("problemFile.php",'wb') Does that help? Also, check the line endings in the actual file (not in the output generated by php), and your auto_detect_line_endings ini setting. ------------------------------------------------------------------------ [2003-04-29 08:03:35] gfraley5 at earthlink dot net This code snippet demonstrates the problem. Under 4.3.1 and prior, it functions correctly. Under 4.3.2 (all versions) it does not function the same and is actually wrong. <? $myArray[] = 'msgid'."\r\n"; $myArray[] = '1049987091'."\r\n"; $myArray[] = '1050930128'."\r\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;?>\r\n"; else $prefx = ""; fwrite($fp,$prefx.$myArray[$i]); } fclose($fp); echo nl2br(readfile("problemFile.php")); ?> Under 4.3.1 and prior, here is the output of problemFile.php: <? Header("HTTP/1.0 403 Forbidden");exit;?> msgid 1049987091 1050930128 Under 4.3.2, here is the output of problemFile.php. Notice the difference in the behaviour of the \r\n: <? Header("HTTP/1.0 403 Forbidden");exit;?> msgid 1049987091 1050930128 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=23406&edit=1

« previous php.bugs (#38718) next »