php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36914 SplFileObject::fwrite() bug
Submitted: 2006-03-29 16:20 UTC Modified: 2006-03-29 17:25 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: c dot affolter at stepping-stone dot ch Assigned:
Status: Not a bug Package: SPL related
PHP Version: 5CVS-2006-03-29 (CVS) OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
38 - 30 = ?
Subscribe to this entry?

 
 [2006-03-29 16:20 UTC] c dot affolter at stepping-stone dot ch
Description:
------------
The bug #36359 doesn't seems to be fixed in the latest CVS version:
http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/internal/splfileobject.inc?view=markup&rev=1.3&pathrev=HEAD

The string to be written ($str) doesn't gets passed to the fwrite() function.

The method SplFileObject::fwrite() has to be corrected:
<?php
...
    function fwrite($str, $length = NULL)

    {
        // wrong:
        //return fwrite($this->fp, $length);

        // correct:
        return fwrite($this->fp, $str, $length);

    }
...
?>


Thanks!


Reproduce code:
---------------
<?php
splFileObject = new FileObject('test.txt', 'w');
splFileObject->fwrite('test');
?>

Expected result:
----------------
cat test.txt
test

Actual result:
--------------
cat test.txt
[empty]

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-29 17:25 UTC] tony2001@php.net
Your code is wrong, but this code works perfectly fine:
<?php
$splFileObject = new SplFileObject('test.txt', 'w');
$splFileObject->fwrite('test');
?>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 16:01:29 2024 UTC