note 76493 deleted from function.intval by googleguy

From: Date: Tue, 22 Oct 2013 06:47:07 +0000
Subject: note 76493 deleted from function.intval by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-196641@lists.php.net to get a copy of this message
Note Submitter: kris at mha dot ca ---- More intval wierdness (tested with PHP 5.2.3 and 4.3.10). <?php $tmp_array = "123,232,141"; if (intval($tmp_array) == $tmp_array) { echo "'".intval($tmp_array)."' equals '$tmp_array'\n"; } else { echo "'".intval($tmp_array)."' does not equal '$tmp_array'\n"; } ?> Output: '123' equals '123,232,141' Odd. Not what was expected. Maybe if I put it into a temporary variable it will normalize itself. <?php $tmp_array = "123,232,141"; $tmp = intval($tmp_array); if ($tmp == $tmp_array) { echo "'$tmp' equals '$tmp_array'\n"; } else { echo "'$tmp' does not equal '$tmp_array'\n"; } ?> Output: '123' equals '123,232,141' I don't know if this is a feature, or a bug in PHP (I would certainly classify this as a bug, but since it is in both PHP 4 and PHP 5 maybe not). If it is a feature, could someone explain it to me?

« previous php.notes (#196641) next »