Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Values {
- private $val;
- function setVal($value){ $this->val = $value; }
- function getVal(){ return $this->val; }
- }
- class Modify {
- private $instance;
- function __construct($instance) {
- $this->instance = $instance;
- }
- function change($val){
- $this->instance->setVal($val);
- }
- }
- $foo = new Values();
- $foo->setVal("cats");
- $bar = new Modify($foo);
- $bar->change("dogs");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement