Created
December 7, 2013 12:19
-
-
Save andrienko/7840464 to your computer and use it in GitHub Desktop.
I did it because I can.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
class a{ | |
public $something; | |
function output(){ | |
echo("A happens!<br>"); | |
} | |
} | |
class b{ | |
public $something; | |
function output(){ | |
echo "Let's do something B<br>"; | |
} | |
} | |
class test{ | |
public $object; | |
function __construct($in="a",$args=null){ | |
if($in=="a")$this->object=new a($args); | |
else $this->object=new b($args); | |
} | |
function __call($name,$args){ | |
return $this->object->$name($args); | |
} | |
function __get($name){ | |
return $this->object->$name; | |
} | |
function __set($name,$value){ | |
return $this->object->$name=$value; | |
} | |
function __isset($name){ | |
return isset($this->object->$name); | |
} | |
function __unset($name){ | |
unset($this->object->$name); | |
} | |
} | |
$myTest=new test("b"); | |
$myTest->output(); | |
$myTest->something="Variable"; | |
echo($myTest->something); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Will produce an object of "a"
Will produce an object of "b"
There even IS a practical approach for that.