Bug #60391 [Com]: fputcsv() returns NULL if first argument is not resource
| From: | me at ktamura dot com | Date: | Sat, 03 Dec 2011 03:08:40 +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-7497@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: me at ktamura dot com
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:
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.
Previous Comments:
------------------------------------------------------------------------
[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