Bug #60391 [Com]: fputcsv() returns NULL if first argument is not resource
| From: | ninzya at inbox dot lv | Date: | Sat, 03 Dec 2011 16:24:46 +0000 |
| Subject: | Bug #60391 [Com]: fputcsv() returns NULL if first argument is not resource | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-7517@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=60391&edit=1
ID: 60391
Comment by: ninzya at inbox dot lv
Reported by: ninzya at inbox dot lv
Summary: fputcsv() returns NULL if first argument is not
resource
Status: Open
Type: Bug
Package: Documentation problem
Operating System: Windows 7
PHP Version: 5.4.0RC2
Block user comment: N
Private report: N
New Comment:
Documentation does not cover the case you have described: "Returns the length of
the written string or FALSE on failure" does not mean "NULL is returned when
zend_parse_parameters returns FAILURE, meaning the types of
the parameters didn't match the function signature".
So from my point of view the problem is either in the code or in the
documentation.
Previous Comments:
------------------------------------------------------------------------
[2011-12-03 03:08:39] me at ktamura dot com
NULL is returned when zend_parse_parameters returns FAILURE, meaning the types of
the parameters didn't match the function signature. This is the behavior for many
other buildin functions such as flock, realpath, etc. I don't think this is a bug.
------------------------------------------------------------------------
[2011-11-26 08:00:46] ninzya at inbox dot lv
Description:
------------
PHP documentation on fputcsv() [http://www.php.net/manual/en/function.fputcsv.php]
says (quote):
"Returns the length of the written string or FALSE on failure".
This is not true if fputcsv() gets a non-resource variable as it's first argument.
In this case it returns NULL.
Test script:
---------------
$arg =true;
//$arg =false;
//$arg =1;
//$arg =null;
//$arg =array();
//$arg =new stdClass;
var_dump( fputcsv( $arg, array( 'x', 'y', 'z')));
Expected result:
----------------
bool(false)
Actual result:
--------------
NULL
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60391&edit=1