Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once 'Nette/loader.php';
- Nette\Diagnostics\Debugger::enable();
- Nette\Diagnostics\Debugger::$strictMode = TRUE;
- class Foo
- {
- private $bar = array(1 => array());
- function &__get($name) // bez & nebude fungovat
- {
- return $this->$name;
- }
- function __set($name, $val)
- {
- $this->$name = $val;
- }
- }
- $foo = new Foo();
- dump($foo->bar);
- $foo->bar[1][2] = 3;
- dump($foo);
- ############################### s novými properties
- class Foo
- {
- private $bar = array(1 => array()) {
- &get { return $this->_bar; } // tady chci mit moznost napsat &
- set { $this->_bar = $value; }
- };
- }
- // abych mohl psát
- $foo->bar[1][2] = 3;
- // místo
- $arr = $foo->bar;
- $arr[1][2] = 3;
- $foo->bar = $arr;
Advertisement
Add Comment
Please, Sign In to add comment