Edit report at http://bugs.php.net/bug.php?id=52163&edit=1
ID: 52163 User updated by: v-ryanbi at microsoft dot com Reported by: 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 Status: Open Type: Bug Package: SPL related Operating System: Windows 7 PHP Version: 5.2.14RC1 New Comment: Argh. typo. In the description it should be SplFileObject::fgetss(). Previous Comments: ------------------------------------------------------------------------ [2010-06-23 21:16:20] v-ryanbi at microsoft dot com 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. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=52163&edit=1