#25243 [NEW]: casting to int behavior weird

From: Date: Tue, 26 Aug 2003 04:21:18 +0000
Subject: #25243 [NEW]: casting to int behavior weird
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-46631@lists.php.net to get a copy of this message
From: elite_eagle67 at hotmail dot com Operating system: windoze PHP version: Irrelevant PHP Bug Type: Scripting Engine problem Bug description: casting to int behavior weird 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 bug report at http://bugs.php.net/?id=25243&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=25243&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=25243&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=25243&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=25243&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=25243&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=25243&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=25243&r=support Expected behavior: http://bugs.php.net/fix.php?id=25243&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=25243&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=25243&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=25243&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=25243&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=25243&r=dst IIS Stability: http://bugs.php.net/fix.php?id=25243&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=25243&r=gnused

« previous php.bugs (#46631) next »