Req #65545 [Opn]: Implement file_get_contents() method for SplFileObject
| From: | datibbaw@php.net | Date: | Wed, 12 Feb 2014 06:14:35 +0000 |
| Subject: | Req #65545 [Opn]: Implement file_get_contents() method for SplFileObject | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-184268@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: Open
Type: Feature/Change Request
Package: SPL related
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
I've added a PR to add fread() as one of the methods you can use, so:
$text = $file->fread($file->getSize());
Previous Comments:
------------------------------------------------------------------------
[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