|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2009-09-20 11:15 UTC] clin dot isbut at gmail dot com
 Description:
------------
empty( $this->variable ) returns always true.
Reproduce code:
---------------
class FooClass
{
    var $publish;
    function foo()
    {
       $this->publish = '123456';
       if( empty( $this->publish ) )
           echo "publish is empty.";
       else
           echo "publish is NOT empty.";
    }
}
Expected result:
----------------
"publish is NOT empty."
Actual result:
--------------
"publish is empty."
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 17:00:02 2025 UTC | 
Ok, I found the root of problems. Seems it fails when the class extends mysqli class (??). See this: Reproduce code: --------------- FooClass.php class FooClass extends mysqli { var $publish_date; function __construct() { } function foo( $var ) { $this->publish_date = $var; echo "Publish_date:".$this->publish_date."<br>"; if( empty( $this->publish_date ) ) echo "publish IS EMPTY!<br>"; else echo "publish IS NOT EMPTY!<br>"; } } Index.php include ("FooClass.php"); $obj = new FooClass(); $obj->foo( '45678' ); Expected result: ---------------- Publish_date: 45678 publish IS NOT EMPTY! Actual result: --------------- Publish_date: 45678 publish IS NOT EMPTY! I expect this time you can reproduce it.