|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-05-29 20:48 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 05 13:00:02 2025 UTC |
Description: ------------ fgets() functions returns a line of text form file when length parameter is <= 0. fgets() should return a warning message indicating that "length parameter should be greater than 0" but returns a line of text when length parameter is <= 0 This failure is only applicable to PHP 6. Consider adding a check for length parameter in the code after paramerts are parsed. if (len <= 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length parameter must be greater than 0"); RETURN_FALSE; } Reproduce code: --------------- <?php $fp = fopen(__FILE__, "r"); var_dump( fgets($fp, 0) ); var_dump( fgets($fp, -10) ); fclose($fp); ?> Expected result: ---------------- Warning: fgets(): Length parameter must be greater than 0 in %s on line %d bool(false) Warning: fgets(): Length parameter must be greater than 0 in %s on line %d bool(false) Actual result: -------------- string(7) "<?php " string(31) " $fp = fopen(__FILE__, "r"); "