|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25815 __get & __set will not fire if the object contains reference to variable
Submitted: 2003-10-09 21:33 UTC Modified: 2004-05-30 14:46 UTC
From: dan at wep dot net Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5 OS: *
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.
Bug Type:
From: dan at wep dot net
New email:
PHP Version: OS:


 [2003-10-09 21:33 UTC] dan at wep dot net
When a class definition contains any reference to a variable name that will be later used in a __set() (or __get()) operation, the setter (or getter) will not fire.

This variable does not have to be defined or used at all. The code must simply exist.

In the following example code, simply comment out the print($this->myVar); line and you will see the 'setter fired' message.

This is NOT similar to bug #24608 as the element never gets created in this case.

Reproduce code:
class test {
  function unusedFunction() {
  function __set($nm, $vl) {
    print('setter fired');

$obj = new test();
$obj->myVar = 'some data';

Expected result:
'setter fired'

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-10 12:21 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

That\'s correct. We have three types of object bound properties:
1) declared with or without default value
2) implicit declared by usage in source (for BC reasons)
3) virtual through __get() and __set()
 [2004-05-30 14:46 UTC]
I have checked the code with current CVS PHP5, and it displays "setter fired".
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 04:01:28 2024 UTC