#33609 [NEW]: function fgets returns error when optional parameter not passed
| From: | php at yvanrodrigues dot com | Date: | Thu, 07 Jul 2005 20:32:22 +0000 |
| Subject: | #33609 [NEW]: function fgets returns error when optional parameter not passed | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-81553@lists.php.net to get a copy of this message | ||
From: php at yvanrodrigues dot com
Operating system: Windows 2000/XP
PHP version: 4.3.11
PHP Bug Type: Filesystem function related
Bug description: function fgets returns error when optional parameter not passed
Description:
------------
function fgets is documented as:
string fgets ( resource handle [, int length] )
however if called with one argument it shows warning:
Warning: Wrong parameter count for fread() in scriptname.php
This has been reported in previous versions (eg bug 15480) and fixed. I
suspect this snuck back in.
The docs say the optional parameter has been in place since 4.2.0 I
believe
Reproduce code:
---------------
for($a=0; !feof($fp); $a++) {
$instring = fread($fp);
$todayarray[$a] = array();
$todayarray[$a]['Course Code'] = trim(substr($instring, 0, 12));
$todayarray[$a]['Section'] = trim(substr($instring, 12, 13));
$todayarray[$a]['Cap'] = trim(substr($instring, 25, 4));
$todayarray[$a]['Enrollment'] = trim(substr($instring, 29, 4));
$todayarray[$a]['Professor'] = trim(substr($instring, 33));
break;
}
Expected result:
----------------
I expect a string to be returned consisting of a line from the file
starting at position 0 of the row and ending when the newline \r\n is
reached.
Actual result:
--------------
php displays an error and dies
--
Edit bug report at http://bugs.php.net/?id=33609&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33609&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33609&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33609&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=33609&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=33609&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=33609&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=33609&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=33609&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=33609&r=support
Expected behavior: http://bugs.php.net/fix.php?id=33609&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=33609&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=33609&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=33609&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33609&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=33609&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=33609&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=33609&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=33609&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=33609&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=33609&r=mysqlcfg