#20018 [Opn->Fbk]: empty($this->property) always returns TRUE inside class method

From: Date: Sat, 02 Nov 2002 17:00:21 +0000
Subject: #20018 [Opn->Fbk]: empty($this->property) always returns TRUE inside class method
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-23946@lists.php.net to get a copy of this message
ID: 20018 Updated by: iliaa@php.net Reported By: tater@potatoe.com -Status: Open +Status: Feedback Bug Type: Zend Engine 2 problem Operating System: OS X 10.1 PHP Version: 4CVS-2002-10-21 New Comment: Please try using this CVS snapshot: http://snaps.php.net/php4-latest.tar.gz For Windows: http://snaps.php.net/win32/php4-win32-latest.zip Previous Comments: ------------------------------------------------------------------------ [2002-10-21 23:28:49] tater@potatoe.com empty() seems to always return TRUE when testing an object property from inside a method of the object. it works OK on regular variables, or when testing the property externally. test code: <?php class test { function test() { $this->x = NULL; print "<li>this->x={$this->x}\n"; print "<li>is this->x empty? ".(empty($this->x) ? "yes" : "no")."\n"; $this->x = 'i am not empty'; print "<li>this->x={$this->x}\n"; print "<li>is this->x empty? ".(empty($this->x) ? "yes" : "no")."\n"; $x = NULL; print "<li>x={$x}\n"; print "<li>is x empty? ".(empty($x) ? "yes" : "no")."\n"; $x = 'i am not empty'; print "<li>x={$x}\n"; print "<li>is x empty? ".(empty($x) ? "yes" : "no")."\n"; } } $x = new test; ?> output: <li>this->x= <li>is this->x empty? yes <li>this->x=i am not empty <li>is this->x empty? yes <li>x= <li>is x empty? yes <li>x=i am not empty <li>is x empty? no ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=20018&edit=1

« previous php.bugs (#23946) next »