예제 #1
0
    public function __get($key)
    {
        return $this->data[$key];
    }
    public function __call($name, $arguments)
    {
        var_dump($name);
        var_dump($arguments);
    }
    public static function __callStatic($name, $arguments)
    {
        var_dump($name);
        var_dump($arguments);
    }
    public function bark()
    {
        echo "Bark!";
    }
    public static function warning()
    {
        echo "Dog Bite!";
    }
}
Dog::run("Pyay", 300);
$dog = new Dog("Aung Net", "Red");
$dog->test = "Testing";
$dog->goo = "Foo";
echo $dog->test;
echo $dog->goo;
$dog->dance("Aung Net", 4);
예제 #2
0
파일: index.php 프로젝트: phpcrazy/wpa21
    public function run()
    {
        // TODO: Implement run() method.
    }
    public function eat()
    {
        // TODO: Implement eat() method.
    }
    public function sleep()
    {
        // TODO: Implement sleep() method.
    }
}
Dog::warning();
// scope resolution operator
Dog::fool("bar");
// late method binding
Dog::bark();
// -------------------
$dog = new Dog();
$dog->color = "Red";
// property binding
// echo $dog->color;
// $dog->warning();
$dog->dance("crazy", "foo", "bar", "moo");
$dog2 = new Dog();
$dog2->bark();
// Singaleton
$cat = new Cat("Shwe War");
$cat->name = "Shwe War";
echo $cat->name;