|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68243 IMPORTANT! Checking empty value failed
Submitted: 2014-10-16 12:25 UTC Modified: 2016-12-11 04:22 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: Siemienik dot Pawel at gmail dot com Assigned: cmb (profile)
Status: No Feedback Package: *PDF functions
PHP Version: 5.5.17 OS: Ubuntu 14
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: Siemienik dot Pawel at gmail dot com
New email:
PHP Version: OS:


 [2014-10-16 12:25 UTC] Siemienik dot Pawel at gmail dot com

Test script:
if(!empty((AnyClass::getInstance()->title)) !== empty(AnyClass::getInstance()->title))
  var_dump('BIG PROBLEM HERE!')


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-10-16 12:27 UTC] siemienik dot pawel at gmail dot com
int AnyClass is function __get(), which will return string value;
 [2014-10-18 16:39 UTC] keithm at aoeex dot com
Works for me

If you believe this is a problem, provide a small but complete test script (including class definitions) which will reproduce the problem.

Test Script:

class A {
        static $instance;
        public static function getInstance(){
                if (!self::$instance){
                        self::$instance=new self;
                return self::$instance;

        public function __get($nm){
                return '';

        , !empty((A::getInstance()->title))
        , !empty((A::getInstance()->title)) !== empty(A::getInstance()->title)


PHP 5.5.9-1ubuntu4.4 (cli) (built: Sep  4 2014 06:56:34)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies

PHP 5.5.18 (cli) (built: Oct 15 2014 13:04:56)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
 [2014-10-18 17:02 UTC] keithm at aoeex dot com
Forgot to try with a non-empty value, which does shows the symptom. 
From the documentation however:

When using empty() on inaccessible object properties, the __isset() overloading method will be called, if declared.

You need to implement __isset() if you want to check whether magic properties exist.

Adding the () inside the empty call means that empty checks the result of the expression, which will be the string value returned by __get.  Without the () PHP will check the if the property exists on the object instead. 

empty(A::getInstance()->title) is equivalent to 
!isset(A::getInstance()->title) || !A::getInstance()->title;

empty((A::getInstance()->title)) is equivalent to
($var = A::getInstance()->title) && (!isset($var) || !$var);
 [2016-12-01 17:27 UTC]
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2016-12-01 17:27 UTC]
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with ,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.
 [2016-12-11 04:22 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 "Re-Opened". Thank you.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 27 13:01:31 2024 UTC