php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9282 printint chr(0x0a) in a file generate 0x0d 0x0a
Submitted: 2001-02-15 10:36 UTC Modified: 2001-02-15 10:48 UTC
From: Olivier dot Ziller at univ-nancy2 dot fr Assigned:
Status: Closed Package: Unknown/Other Function
PHP Version: 4.0.4pl1 OS: Win32
Private report: No CVE-ID: None
 [2001-02-15 10:36 UTC] Olivier dot Ziller at univ-nancy2 dot fr
look at the following code :

<?
  $s = chr(0x0a);
  print strlen($s);
  $fp =fopen("test.txt","w");
  fwrite($fp,$s,1);
  fclose($fp);
?>

the output on screen is 1(strlen($s)) but in my file, i get always 0x0d 0x0a.
With Unix, i get only 0x0a in my file.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-02-15 10:48 UTC] hholzgra@php.net
this is how windows (aka MS-DOS) works,
to write transparent binary to a file you have to 
open it with mode "wb" instead of "w"
(unix will accept the 'b' too although it has no effect there)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 13:01:28 2024 UTC