php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49606 empty( $this->variable )
Submitted: 2009-09-20 11:15 UTC Modified: 2013-02-18 00:34 UTC
From: clin dot isbut at gmail dot com Assigned:
Status: No Feedback Package: Scripting Engine problem
PHP Version: 5.3.0 OS: Windows Xp
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: clin dot isbut at gmail dot com
New email:
PHP Version: OS:

 

 [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."

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-09-20 17:23 UTC] jani@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

Works fine for me..
 [2009-09-20 17:45 UTC] clin dot isbut at gmail dot com
Seems like my example code does not reproduce the error. I'll try to reduce my failing code to write here.
 [2009-09-20 18:14 UTC] clin dot isbut at gmail dot com
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.
 [2009-09-20 18:25 UTC] clin dot isbut at gmail dot com
Sorry, expected and actual result are as this:

Expected result:
----------------
   Publish_date: 45678
   publish IS NOT EMPTY!

Actual result:
---------------
   Publish_date: 45678
   publish IS EMPTY!
 [2009-09-22 10:15 UTC] jani@php.net
I still can not reproduce this with the class extending mysqli. Please try the snapshot. (And next time, DO NOT use the "Add comment" tab when you add comments to your _own_ report! Use the "Edit Submission" tab!)
 [2009-09-30 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2010-03-07 18:14 UTC] felipe@php.net
-Status: No Feedback +Status: Feedback
 [2010-03-07 18:14 UTC] felipe@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2013-02-18 00:34 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sat Dec 03 02:05:54 2022 UTC