#50255 [Opn->Bgs]: isset and empty returns wrong value

From: Date: Sat, 21 Nov 2009 15:00:19 +0000
Subject: #50255 [Opn->Bgs]: isset and empty returns wrong value
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-144908@lists.php.net to get a copy of this message
ID: 50255 Updated by: jani@php.net Reported By: tyra3l at gmail dot com -Status: Open +Status: Bogus Bug Type: *General Issues Operating System: windows xp PHP Version: 5.3.1 New Comment: Please do not submit the same bug more than once. An existing bug report already describes this very problem. Even if you feel that your issue is somewhat different, the resolution is likely to be the same. Thank you for your interest in PHP. And expected behaviour. RTFM. etc. Previous Comments: ------------------------------------------------------------------------ [2009-11-21 10:08:26] tyra3l at gmail dot com Description: ------------ If you try to check the existence of a property on an array, suprisingly you wont get any error or notice, but you will get the results as you were checking with the correct type. Reproduce code: --------------- <?php $a = array('foo' => 'bar'); echo "<pre>";var_dump(isset($a->foo));echo "</pre>"; echo "<pre>";var_dump(isset($a->asd));echo "</pre>"; echo "<pre>";var_dump(empty($a->foo));echo "</pre>"; echo "<pre>";var_dump(empty($a->asd));echo "</pre>"; echo "<pre>";var_dump(@$a->foo);echo "</pre>"; Expected result: ---------------- Fatal error: Cannot use array as object in ... OR bool(false) bool(false) bool(true) bool(true) NULL Actual result: -------------- bool(true) bool(false) bool(false) bool(true) NULL ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=50255&edit=1

« previous php.bugs (#144908) next »