Equivalency of null

From: Date: Tue, 08 Aug 2006 01:59:19 +0000
Subject: Equivalency of null
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-24854@lists.php.net to get a copy of this message
1) null == '' 2) null == array() 3) array() != '' Item 3 surprised me. I wrote a little table to make sure I wasn't seeing things. Can anyone add a word of explanation as to why 3) is not false, when 1) and 2) are true? --- null.php ----- <?php //Equivalency of null // 1) null == '' // 2) null == array() // 3) array() != '' ?> <table rules="all" frame="box"> <caption>Equivalency of Null</caption> <thead><tr><th>Expression</th><th>Returns</th></tr></thead> <tbody> <?php $result = '' == null ? 'true' : 'false' ; echo '<tr><td><code>\'\' == null</code></td>'; echo '<td><code>' . $result . '</code></td></tr>'; $result = array() == null ? 'true' : 'false'; echo '<tr><td><code>array() == null</code></td>'; echo '<td><code>' . $result . '</code></td></tr>'; $result = array() == '' ? 'true' : 'false'; echo '<tr><td><code>array() == \'\'</code></td>'; echo '<td><code>' . $result . '</code></td></tr>'; ?> </tbody> </table> --- end of null.php --- LFaR.

« previous php.pear.general (#24854) next »