note 83769 deleted from function.intval by cmb

From: Date: Sun, 16 Feb 2020 13:47:28 +0000
Subject: note 83769 deleted from function.intval by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-214137@lists.php.net to get a copy of this message
Note Submitter: phpben hood id au ---- kris at mha dot ca: Implicit typing. This is a feature, not a bug. The == operator will convert your string to an int automatically (in this case) so that it is really comparing 123 and 123, which is of course the same. If you use the === operator then this will not occur, as it will only match on the same value and type. This works as expected: <?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"; } ?>

« previous php.notes (#214137) next »