Overloading Limitation- Can Someone Confirm?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



While playing with an unnamed framework, I think I discovered an overloading limitation (PHP 5.1.2). Can someone please confirm this limitation?

Example class:

class testClass
{
    public $vars = array();

    public function __get($key)
    {
return array_key_exists($key, $this->vars) ? $this->vars [$key] : null;
    }

    public function __set($key, $value)
    {
        $this->vars[$key] = $value;
    }

    public function __isset($key)
    {
        return array_key_exists($key, $this->vars);
    }

    public function __unset($key)
    {
        unset($this->vars[$key]);
    }
}


Given the above class, the following code will not work:

$tc = new testClass();

$tc->arr = array();

$tc->arr['a'] = 'A';
$tc->arr['b'] = 'B';

if (isset($tc->arr['b'])) {
    unset($tc->arr['b']);
}

//var_dump is only to see results of above
var_dump($tc);

Am I a moron or, in fact, does this not work and is a language limitation?

Chris
chris@xxxxxxxxxxxxxxxxx

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux