public function offsetSet($key, $val) {
$this->container[$key] = $val;
}
public function &offsetGet($key) {
return $this->container[$key];
}
public function offsetExists($key) {
return array_key_exists($key, $this->container);
}
public function offsetUnset($key) {
unset($this->container[$key]);
}
}
$a = new X();
$a["test"] = 123;
echo $a["test"]; // output 123
Perfect code sample to solve the problem
Обсуждают сегодня