Skip to content

Instantly share code, notes, and snippets.

@rmasters
Created March 6, 2014 17:07
Show Gist options
  • Save rmasters/9394503 to your computer and use it in GitHub Desktop.
Save rmasters/9394503 to your computer and use it in GitHub Desktop.
<?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