#25243 [Opn->Bgs]: casting to int behavior weird
| From: | sniper@php.net | Date: | Tue, 26 Aug 2003 04:27:20 +0000 |
| Subject: | #25243 [Opn->Bgs]: casting to int behavior weird | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-46632@lists.php.net to get a copy of this message | ||
ID: 25243
Updated by: sniper@php.net
Reported By: elite_eagle67 at hotmail dot com
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: windoze
PHP Version: Irrelevant
New Comment:
RTFM:
http://www.php.net/manual/en/language.types.integer.php#language.types.integer.casting
Previous Comments:
------------------------------------------------------------------------
[2003-08-25 23:21:18] elite_eagle67 at hotmail dot com
Description:
------------
Do (int)$var where $var is an array that has some kind of value stored,
and the return value will be 1, not 0.
Now this obviously doesn't make sense as you cast to (int) so you can
see if a variable has a valid INTEGER variable, NOT if it is the
integer equivilent of a * boolean * value.
Ofcourse, an empty array in this example will return 0, as would be
expected behavior for a BOOLEAN cast, not integer howerever...
I'm unaware how (string) cast deals with this, possibly similiar but if
so, then just apply this bug report to that ;)
Reproduce code:
---------------
$array = array( 'yay' => 'boo!' );
if((int)$array) {
echo (int)$array;
} else {
echo (int)$array;
}
Expected result:
----------------
0
Actual result:
--------------
1
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=25243&edit=1