|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-07-11 08:16 UTC] ab@php.net
-Status: Open
+Status: Not a bug
[2013-07-11 08:16 UTC] ab@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 22:00:01 2025 UTC |
Description: ------------ I don't know whether this is a bug or a documentation problem. In SplFileObject::fgets documentation, Example is shown as following: <?php $file = new SplFileObject("file.txt"); while (!$file->eof()) { echo $file->fgets(); } ?> But this should be: <?php $file = new SplFileObject("file.txt"); while (($buffer = $file->fgets("file.txt")) !== "") { echo $buffer; } ?> I show you the test script. Test script: --------------- <?php $arr = array(); $file = new SplFileObject("empty_file.txt"); while (!$file->eof()) { $arr[] = $file->fgets(); } var_dump($arr); Expected result: ---------------- array(1) { [0]=> bool(false) } # Actually, this substitution should not occurr. Actual result: -------------- array(1) { [0]=> string(0) "" } # I think this can give us lots confusion.