Advertisement
Guest User

Untitled

a guest
Aug 9th, 2012
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.39 KB | None | 0 0
  1. <?php
  2. class Values {
  3.     private $val;
  4.     function setVal($value){ $this->val = $value; }
  5.     function getVal(){ return $this->val; }
  6. }
  7. class Modify {
  8.     private $instance;
  9.     function __construct($instance) {
  10.         $this->instance = $instance;
  11.     }
  12.     function change($val){
  13.         $this->instance->setVal($val);
  14.     }
  15. }
  16.  
  17. $foo = new Values();
  18. $foo->setVal("cats");
  19. $bar = new Modify($foo);
  20. $bar->change("dogs");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement