php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41742 When using a language construct, magic functions are not called in a object
Submitted: 2007-06-19 20:51 UTC Modified: 2007-06-19 21:06 UTC
From: gatorv at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.2.3 OS: Windows Vista
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: gatorv at gmail dot com
New email:
PHP Version: OS:

 

 [2007-06-19 20:51 UTC] gatorv at gmail dot com
Description:
------------
If you use a language construct ej: empty on a object and want to call a magic function ej: __get, the function is not called and the function fails.

Reproduce code:
---------------
class Test {
     public $input;

     public function __construct() {
          $this->input = array( "foo" => "bar" );
     }

     public function __get( $var ) {
         return $this->input[$var];
     }
}

$test = new Test();
if( empty( $test->foo ) ) {
     echo "Foo on Test is empty";
} else {
     echo "Foo on Test is not empty";
}

Expected result:
----------------
Foo on Test is not empty.

Actual result:
--------------
Foo on Test is empty

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-06-19 21:06 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

You need to implement __isset() to catch this.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Jul 16 12:00:01 2026 UTC