#36914 [Opn->Bgs]: SplFileObject::fwrite() bug

From: Date: Wed, 29 Mar 2006 15:25:48 +0000
Subject: #36914 [Opn->Bgs]: SplFileObject::fwrite() bug
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-95087@lists.php.net to get a copy of this message
ID: 36914 Updated by: tony2001@php.net Reported By: c dot affolter at stepping-stone dot ch -Status: Open +Status: Bogus Bug Type: SPL related Operating System: Linux PHP Version: 5CVS-2006-03-29 (CVS) New Comment: Your code is wrong, but this code works perfectly fine: <?php $splFileObject = new SplFileObject('test.txt', 'w'); $splFileObject->fwrite('test'); ?> Previous Comments: ------------------------------------------------------------------------ [2006-03-29 16:20:36] 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] ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=36914&edit=1

« previous php.bugs (#95087) next »