note 99654 deleted from function.settype by danbrown

From: Date: Sat, 02 Feb 2013 15:15:41 +0000
Subject: note 99654 deleted from function.settype by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-193504@lists.php.net to get a copy of this message
Note Submitter: contact[at]covac-software[dot]com ---- With reply to Chris Sullins and Michael Benedict, I don't find this behavior strange: <?php echo var_dump( (int)'' ); // int(0) echo var_dump( (float)array('a'=>'b') ); // float(1) ?> This is due to the fact that an uninitialized variable is null, which converts to a 0. As does boolean false or an empty string or array. When a value is not empty, such as my above array, it is converted to a 1 (integer/float) or true (boolean). When changing between arrays and objects, it of course made sense to keep the fields intact (array key/values and object properties/values). Cheers, Chris.

« previous php.notes (#193504) next »