| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
  [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
PatchesPull Requests
Pull requests: 
 HistoryAllCommentsChangesGit/SVN commits             
             | 
    |||||||||||||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 06:00:01 2025 UTC | 
I've added a PR to add fread() as one of the methods you can use, so: $text = $file->fread($file->getSize());