php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49499 get and set are not fixed
Submitted: 2009-09-08 11:32 UTC Modified: 2009-09-08 14:41 UTC
From: ies_clan at hotmail dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.3.0 OS: Windows XP home
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ies_clan at hotmail dot com
New email:
PHP Version: OS:

 

 [2009-09-08 11:32 UTC] ies_clan at hotmail dot com
Description:
------------
look @ the code....

Reproduce code:
---------------
<?php

error_reporting(E_ALL);

class newclass {
  private $properties;

  public function &__get($key) {
    echo "get $key<br>";
    return $this->properties[$key];
  }

  public function __set($key, $val) {
    echo "set $key to $val<br>";
    $this->properties[$key] = $val;
  }
}

$c = new newclass;
$c->array['test'] = 'test';

Expected result:
----------------
get array
set array to test

Actual result:
--------------
get array

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-09-08 14:41 UTC] sjoerd@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

The __get() function returns a reference to the array, and this reference is used to change the array.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 11:01:34 2025 UTC