PHP利用可变函数动态扩增类的属性

 'home.php',
        'Contact' => 'contact.php',
        'Services' => 'services.php',
        'Site Map' => 'map.php'
    );

    public function __set($name,$value){
        $this->$name = $value;
        print_r($this);
    }
}

$page = new Page();
$page->__set('a333','12312');
echo $page->a333;

你可能感兴趣的:(笔记)