HosipLan

Untitled

Mar 29th, 2012
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. require_once 'Nette/loader.php';
  4. Nette\Diagnostics\Debugger::enable();
  5. Nette\Diagnostics\Debugger::$strictMode = TRUE;
  6.  
  7.  
  8. class Foo
  9. {
  10.  
  11.     private $bar = array(1 => array());
  12.  
  13.     function &__get($name) // bez & nebude fungovat
  14.     {
  15.         return $this->$name;
  16.     }
  17.  
  18.     function __set($name, $val)
  19.     {
  20.         $this->$name = $val;
  21.     }
  22.  
  23. }
  24.  
  25.  
  26. $foo = new Foo();
  27. dump($foo->bar);
  28.  
  29. $foo->bar[1][2] = 3;
  30. dump($foo);
  31.  
  32.  
  33.  
  34. ############################### s novými properties
  35.  
  36.  
  37. class Foo
  38. {
  39.     private $bar = array(1 => array()) {
  40.         &get { return $this->_bar; } // tady chci mit moznost napsat &
  41.         set { $this->_bar = $value; }
  42.     };
  43. }
  44.  
  45. // abych mohl psát
  46.  
  47. $foo->bar[1][2] = 3;
  48.  
  49. // místo
  50.  
  51. $arr = $foo->bar;
  52. $arr[1][2] = 3;
  53. $foo->bar = $arr;
Advertisement
Add Comment
Please, Sign In to add comment