#50311 [Opn->Csd]: intval() vs floatval(): same behavior but different documentation
| From: | degeberg@php.net | Date: | Sat, 19 Dec 2009 11:00:25 +0000 |
| Subject: | #50311 [Opn->Csd]: intval() vs floatval(): same behavior but different documentation | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-3514@lists.php.net to get a copy of this message | ||
ID: 50311
Updated by: degeberg@php.net
Reported By: php-qa at sebastianmendel dot de
-Status: Open
+Status: Closed
Bug Type: Documentation problem
PHP Version: Irrelevant
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation
better.
Previous Comments:
------------------------------------------------------------------------
[2009-12-19 10:59:29] svn@php.net
Automatic comment from SVN on behalf of degeberg
Revision: http://svn.php.net/viewvc/?view=revision&revision=292325
Log: Fixed #50311.
------------------------------------------------------------------------
[2009-11-27 12:13:48] php-qa at sebastianmendel dot de
Description:
------------
the parameter and return description for floatval() and intval()
differs
but both behave exactly the same way
floatval(): var - May be any scalar type. You cannot use floatval() on
arrays or objects.
intval(): var - The scalar value being converted to an integer
Return Values: [...] Empty arrays and objects return 0, non-empty
arrays and objects return 1.
but both functions are accepting array as var and throw notice on
objects
Reproduce code:
---------------
echo intval(array()); // 0
echo intval(array(1,2,3)); // 1
echo intval(new stdClass); // 1
Notice: Object of class stdClass could not be converted to int in php
shell code on line 1
echo floatval(array()); // 0
echo floatval(array(1,2,3)); // 1
echo floatval(new stdClass); // 1
Notice: Object of class stdClass could not be converted to double in
php shell code on line 1
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=50311&edit=1