|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-06-23 21:18 UTC] v-ryanbi at microsoft dot com
-Summary: fails due to parameter that can't be set
+Summary: SplFileObject::fgetss() fails due to parameter that
can't be set
[2010-06-23 21:18 UTC] v-ryanbi at microsoft dot com
[2010-06-25 01:10 UTC] felipe@php.net
[2010-06-25 01:11 UTC] felipe@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: felipe
[2010-06-25 01:11 UTC] felipe@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 23:00:01 2025 UTC |
Description: ------------ When calling SplFileObject::ffgetss() in 5.2.x (including the 5.2.14 RC1), a warning is thrown and the cursor is *not* advanced. Since this would typically be used in a while(!$fileObj->eof()) loop, it can result in an infinite loop. The complaint thrown in the warning is that the Length parameter must be greater than 0. While Length is a valid parameter in the global fgetss function, the SPL version of this function only accepts one parameter, and that is for accepted tags. Test script: --------------- <?php $str = <<<EOD <html><body> <p>Welcome! Today is the <?php echo(date('jS')); ?> of <?= date('F'); ?>.</p> </body></html> Text outside of the HTML block. EOD; $filePath="filename.php"; file_put_contents($filePath, $str); $fileObject = new SplFileObject($filePath); while (!$fileObject->eof()) { echo $fileObject->fgetss('body'); } ?> Expected result: ---------------- Welcome! Today is the of . Text outside of the HTML block. Actual result: -------------- Warning: fgetss(): Length parameter must be greater than 0 in C:\fgetssBug\fgetss_basic.php on line 13 Warning: fgetss(): Length parameter must be greater than 0 in C:\fgetssBug\fgetss_basic.php on line 13 Warning: fgetss(): Length parameter must be greater than 0 in C:\fgetssBug\fgetss_basic.php on line 13 Warning: fgetss(): Length parameter must be greater than 0 in C:\fgetssBug\fgetss_basic.php on line 13 Warning: fgetss(): Length parameter must be greater than 0 in C:\fgetssBug\fgetss_basic.php on line 13 Warning: fgetss(): Length parameter must be greater than 0 in C:\fgetssBug\fgetss_basic.php on line 13 Warning: fgetss(): Length parameter must be greater than 0 in C:\fgetssBug\fgetss_basic.php on line 13 Warning: fgetss(): Length parameter must be greater than 0 in C:\fgetssBug\fgetss_basic.php on line 13 ... and on to infinity.