|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2012-02-09 20:22 UTC] rasmus@php.net
[2012-02-09 20:22 UTC] rasmus@php.net
-Status: Open
+Status: Analyzed
[2012-02-09 22:25 UTC] rasmus@php.net
[2012-02-09 22:46 UTC] jcampbell at remindermedia dot com
[2016-06-29 12:40 UTC] cmb@php.net
[2020-11-03 17:56 UTC] cmb@php.net
-Status: Analyzed
+Status: Not a bug
-Assigned To:
+Assigned To: cmb
[2020-11-03 17:56 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 17:00:01 2025 UTC |
Description: ------------ Suddenly, using SplFileObject::SKIP_EMPTY and SplFileObject::DROP_NEW_LINE no longer ignores a final blank line in a file. Instead, when iterating over the file object, the last value is boolean false. This appears to have changed between 5.3.8 and 5.3.9 and persists in 5.3.10. Test script: --------------- <?php $filename = "/tmp/test-file.txt"; file_put_contents($filename, "non-blank line1" . PHP_EOL); file_put_contents($filename, "non-blank line2" . PHP_EOL, FILE_APPEND); $TheFile = new SplFileObject($filename, "r"); $TheFile->setFlags( SplFileObject::SKIP_EMPTY | SplFileObject::DROP_NEW_LINE ); foreach ($TheFile as $line) { print "Currently on key " . $TheFile->key() . ": " . PHP_EOL; var_dump($line); } Expected result: ---------------- Currently on key 0: string(15) "non-blank line1" Currently on key 1: string(15) "non-blank line2" Actual result: -------------- Currently on key 0: string(15) "non-blank line1" Currently on key 1: string(15) "non-blank line2" Currently on key 2: bool(false)