php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43885 Object model
Submitted: 2008-01-17 21:34 UTC Modified: 2008-01-28 23:30 UTC
From: vbaryshev at list dot ru Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 6CVS-2008-01-17 (snap) OS: Windows XP
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: vbaryshev at list dot ru
New email:
PHP Version: OS:

 

 [2008-01-17 21:34 UTC] vbaryshev at list dot ru
Description:
------------
Some bugs with __get(), __set()

Reproduce code:
---------------
class Test1
{
    public function __construct() { }
    public function test()
    {
        $this->Prop = 'test';
        echo $this->Prop;
        echo isset($this->Prop);
        echo !empty($this->Prop);
        echo $this->Prop;
    }
}
class Test2 extends Test1
{
    private $prop;
    public function __construct() { }
    public function __get($name)
    {
        $name{0} = strtolower($name{0}); // Property called with first symbol upper case
        switch ($name)
        {
            case "prop" :
                return $this->prop;
                break;
        }
    }
    public function __set($name, $value)
    {
        $name{0} = strtolower($name{0}); // Property called with first symbol upper case
        switch ($name)
        {
            case "prop" :
                $this->prop = $value;
                break;
        }
    }
}
$obj = new Test2();
$obj->test();


Expected result:
----------------
test
{false}
{false}
test

Actual result:
--------------
test
1
1
test

??????? ??????? ?? ???????????? ???????????? ?????????, ??? ???????? ???????? ? ?????????? ????? ?????? ? ?????????? ????????? ????????? ???????? ? ???????????? ????? ??????.
Sory, my english very bad :(

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-28 23:30 UTC] tony2001@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

http://www.php.net/manual/en/language.oop5.overloading.php
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Dec 17 10:00:01 2025 UTC