php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23014 Wrong output with funtion fwrite(), fputs()
Submitted: 2003-04-02 04:35 UTC Modified: 2003-04-23 04:18 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: c dot ferrari at gmx dot net Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 4.3.2RC1 OS: Windows XP
Private report: No CVE-ID: None
 [2003-04-02 04:35 UTC] c dot ferrari at gmx dot net
Since PHP version 4.3.1 an also in version 4.3.2RC1 I have found some problems with the function fputs() fwrite().
If you write only one character the functinon write two!!
Example 1:
<?php
$fp=fopen("test.txt","w+");
fputs($fp, "*");
fclose($fp);
?>
Result:
With a Hexeditor you can see 2A 0A.

Example 2:
<?php
$fp=fopen("test.txt","w+");
fputs($fp, "**");
fclose($fp);
?>
Result:
With a Hexeditor you can see the correct result  2A 2A.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-04-07 18:43 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 [2003-04-11 08:41 UTC] c dot ferrari at gmx dot net
There ist definitly a problem in this both function 
fgets(), fwrite() or in the function fopen()!
It look's like a problem with the binary option in the function fopen().
If I use fopen($fp,"wb+") in the PHP version 4.3.2RC1 it works similar like fopen($fp, "w+") in the PHP version 4.2.3 and 4.3.0 . If it's not so, why this functions works so different from PHP 4.3.2RC1 and 4.3.0 and 4.2.x.
 [2003-04-23 04:18 UTC] sniper@php.net
.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 17:01:30 2024 UTC