|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-11-02 11:00 UTC] iliaa@php.net
[2002-11-02 23:04 UTC] tater at potatoe dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 31 06:00:02 2025 UTC |
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