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