php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #65545 Implement file_get_contents() method for SplFileObject
Submitted: 2013-08-25 01:31 UTC Modified: 2014-03-07 11:07 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: sherifsabry20000 at gmail dot com Assigned: datibbaw (profile)
Status: Closed Package: SPL related
PHP Version: Irrelevant OS:
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:
33 + 28 = ?
Subscribe to this entry?

 
 [2013-08-25 01:31 UTC] 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



Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-02-12 06:14 UTC] 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());
 [2014-03-07 10:44 UTC] datibbaw@php.net
-Assigned To: +Assigned To: datibbaw
 [2014-03-07 11:07 UTC] datibbaw@php.net
-Status: Assigned +Status: Closed
 [2014-03-07 11:07 UTC] datibbaw@php.net
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.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 13:01:30 2024 UTC