Req #65545 [Asn->Csd]: Implement file_get_contents() method for SplFileObject

From: Date: Fri, 07 Mar 2014 11:07:10 +0000
Subject: Req #65545 [Asn->Csd]: Implement file_get_contents() method for SplFileObject
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-184597@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=65545&edit=1

 ID:                 65545
 Updated by:         datibbaw@php.net
 Reported by:        sherifsabry20000 at gmail dot com
 Summary:            Implement file_get_contents() method for
                     SplFileObject
-Status:             Assigned
+Status:             Closed
 Type:               Feature/Change Request
 Package:            SPL related
 PHP Version:        Irrelevant
 Assigned To:        datibbaw
 Block user comment: N
 Private report:     N

 New Comment:

The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.




Previous Comments:
------------------------------------------------------------------------
[2014-02-12 06:14:35] datibbaw@php.net

I've added a PR to add fread() as one of the methods you can use, so:

    $text = $file->fread($file->getSize());

------------------------------------------------------------------------
[2013-08-25 01:31:54] sherifsabry20000 at gmail dot com

Description:
------------
It'd be nice to have native support for reading whole files in SplFileObject. At 
the moment one would have to read a file line by line to get the whole text.

So instead of:

    $file = new SplFileObject( "one.php" );
    $text='';
    foreach( $file as $line ) {
        $text.=$line;
    } 
    //$text now has the contents of the file

We could do this:

    $file = new SplFileObject( "one.php" );
    $text= $file->getContents();
    //$text now has the contents of the file




------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=65545&edit=1


Thread (3 messages)

« previous php.bugs (#184597) next »