note 37777 deleted from function.fopen by pollita

From: Date: Wed, 26 Nov 2003 19:22:15 +0000
Subject: note 37777 deleted from function.fopen by pollita
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-61006@lists.php.net to get a copy of this message
Note Submitter: ckitchin ---- Ver 4.3.1 for Windows Writing in text mode does not play nicely with Heredoc (<<<) in MS-DOS. Example: $fp= fopen('file.txt', 'wt'); fwrite($fp, <<<ENDTEXT One line of text Another line of text Last line of text\n ENDTEXT ); fclose($fp); Will write this to the file: One line of text\r\r\n Another line of text\r\r\n Last line of text\r\n The <<< heredoc is picking up the \r\n from the php file and then text mode is adding another \r. As an example of the errors this can cause, a dos batch file created this way will not work (Win98). Until stream_filter_register is available (it's PHP 5 CVS now), or text-mode is corrected (if this is deemed a bug), you use this code: function fwrite2($res,$st) { fwrite($res, str_replace("\r",'',$st)); } and change your fwrite()'s to fwrite2()'s.

« previous php.notes (#61006) next »