Properties get Demo : Properties get : Class PHP Source Code


PHP Source Code » Class » Properties get »

 

Properties get Demo



<?php
class Person {
    function __get$property ) {
        $method = "get{$property}";
        if method_exists$this, $method ) ) {
            return $this->$method();
        }
    }
                                                                                
    function getName() {
        return "Joe";
    }
                                                                                
    function getAge() {
        return 31;
    }
}

$p = new Person();
print $p->name;
?>


           
       



HTML code for linking to this page:

Follow Navioo On Twitter

PHP Source Code

 Navioo Class
» Properties get