From: [EMAIL PROTECTED]
Operating system: OS X 10.1
PHP version: 4CVS-2002-10-21
PHP Bug Type: Zend Engine 2 problem
Bug description: empty($this->property) always returns TRUE inside class method
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 bug report at http://bugs.php.net/?id=20018&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=20018&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=20018&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=20018&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=20018&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=20018&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=20018&r=support
Expected behavior: http://bugs.php.net/fix.php?id=20018&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=20018&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=20018&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=20018&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=20018&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=20018&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=20018&r=isapi