Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 9th, 2012  |  syntax: PHP  |  size: 0.39 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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");