#33609 [Bgs]: function fgets returns error when optional parameter not passed
| From: | php at yvanrodrigues dot com | Date: | Thu, 07 Jul 2005 23:49:30 +0000 |
| Subject: | #33609 [Bgs]: function fgets returns error when optional parameter not passed | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-81566@lists.php.net to get a copy of this message | ||
ID: 33609
User updated by: php at yvanrodrigues dot com
Reported By: php at yvanrodrigues dot com
Status: Bogus
Bug Type: Filesystem function related
Operating System: Windows 2000/XP
PHP Version: 4.3.11
New Comment:
damn, my mind must have been elsewhere when I wrote that line of code.
Sorry for the crazy-talk
Previous Comments:
------------------------------------------------------------------------
[2005-07-07 22:38:47] tony2001@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
fread() & fgets() are 2 different functions.
------------------------------------------------------------------------
[2005-07-07 22:32:15] php at yvanrodrigues dot com
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 this bug report at http://bugs.php.net/?id=33609&edit=1