#24436 [Opn->Csd]: isset() and empty() produce errors with non-existent variables in classes

From: Date: Sat, 05 Jul 2003 15:17:08 +0000
Subject: #24436 [Opn->Csd]: isset() and empty() produce errors with non-existent variables in classes
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-43298@lists.php.net to get a copy of this message
ID: 24436 Updated by: sterling@php.net Reported By: Nico dot Laus dot 2002 at gmx dot de -Status: Open +Status: Closed Bug Type: Zend Engine 2 problem Operating System: WinXP SP1 PHP Version: 5CVS-2003-07-01 (dev) New Comment: This bug has been fixed in CVS. In case this was a PHP problem, snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. In case this was a documentation problem, the fix will show up soon at http://www.php.net/manual/. In case this was a PHP.net website problem, the change will show up on the PHP.net site and on the mirror sites in short time. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2003-07-01 09:52:36] derick@php.net FYI: It wasn't a setting, it was me messing with the code ;-) ------------------------------------------------------------------------ [2003-07-01 09:51:29] Nico dot Laus dot 2001 at gmx dot de same with me - I had the same output with your code and btw: I haven't found any setting for this in php.ini ------------------------------------------------------------------------ [2003-07-01 09:43:09] postings-php-bug at hans-spath dot de This is really weird: ===> CODE 1 <=== <? error_reporting( E_ALL ); define( 'N', "\n" ); class test { function test() { echo "test\n"; if( empty($this->a[0][0]) ) echo 'empty($this->a[0][0])', N; if( empty($this->a[0]) ) echo 'empty($this->a[0])', N; if( empty($this->a) ) echo 'empty($this->a)', N; if( ! isset($this->a) ) echo 'isset($this->a)', N; if( ! isset($this->a[0]) ) echo 'isset($this->a[0])', N; if( ! isset($this->a[0][0]) ) echo 'isset($this->a[0][0])', N; } } $x = new test(); ===> OUTPUT (CODE 1) <=== test empty($this->a[0][0]) empty($this->a[0]) empty($this->a) isset($this->a) isset($this->a[0]) isset($this->a[0][0]) ===> CODE 2 <=== <? error_reporting( E_ALL ); define( 'N', "\n" ); class test { function test() { echo "test\n"; if( empty($this->a[0][0]) ) echo 'empty($this->a[0][0])', N; // if( empty($this->a[0]) ) echo 'empty($this->a[0])', N; // if( empty($this->a) ) echo 'empty($this->a)', N; // if( ! isset($this->a) ) echo 'isset($this->a)', N; // if( ! isset($this->a[0]) ) echo 'isset($this->a[0])', N; if( ! isset($this->a[0][0]) ) echo 'isset($this->a[0][0])', N; } } $x = new test(); ===> OUTPUT (CODE 2) <=== PHP Notice: Undefined property: test::$a in M:\php\test.php on line 8 PHP Notice: Undefined property: test::$a in M:\php\test.php on line 13 test <br /> <b>Notice</b>: Undefined property: test::$a in <b>M:\php\test.php</b> on line <b>8</b><br /> empty($this->a[0][0]) <br /> <b>Notice</b>: Undefined property: test::$a in <b>M:\php\test.php</b> on line <b>13</b><br /> isset($this->a[0][0]) ===> PHP Version <=== PHP 5.0.0b2-dev (cgi-fcgi) (built: Jul 1 2003 12:10:02) Copyright (c) 1997-2003 The PHP Group Zend Engine v2.0.0-dev, Copyright (c) 1998-2003 Zend Technologies ------------------------------------------------------------------------ [2003-07-01 09:40:12] Nico dot Laus dot 2001 at gmx dot de hmmm, I will check my php.ini, maybe I can configure my php in the way yours is, that no such errors are displayed (this is what I want) -> I'll let you know whether I can change this with php.ini or it is really a bug ;) ------------------------------------------------------------------------ [2003-07-01 09:29:43] derick@php.net Ah, no, that was my fault, it gives errors now. But no errors *at all* with this: <?php error_reporting(E_ALL); class test { function __construct() { if (empty($this->test[0][0])) { print "test1\n";} if (!isset($this->test[0][0])) { print "test2\n";} if (empty($this->test)) { print "test1\n";} if (!isset($this->test)) { print "test2\n";} } } $test1 = new test(); ?> Here it should have given 3 errors, for both the [0][0] ones, and the empty($this->test) one. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/24436 -- Edit this bug report at http://bugs.php.net/?id=24436&edit=1

« previous php.bugs (#43298) next »