Created
March 6, 2014 17:07
-
-
Save rmasters/9394503 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
class Magical { | |
public $name = 'The Penguin'; | |
protected $realName = 'Jack Snow'; | |
private $reallyRealName = 'Santa Claus'; | |
public function getAge() { | |
return 42; | |
} | |
protected function getRealAge() { | |
return 12; | |
} | |
public function __get($property) { | |
echo "You tried to get the property $property\n"; | |
} | |
public function __set($property, $value) { | |
echo "You tried to set the property $property to $value\n"; | |
} | |
public function __call($method, array $args) { | |
echo "You called the method $method(" . implode(", ", $args) . ")\n"; | |
} | |
} | |
$m = new Magical; | |
echo $m->name . "\n"; | |
echo $m->realName . "\n"; | |
echo $m->reallyRealName . "\n"; | |
echo $m->getAge() . "\n"; | |
echo $m->getRealAge() . "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment