復制代碼 代碼如下:
class test{
    private $name;
    private $sex;
    function __construct(){
        $this->aaa='aaa';
    }
}
$test=new test();
$reflect=new ReflectionClass($test);
$pro=$reflect->getDefaultProperties();
print_r($pro);//打印結果:Array ( [name] => [sex] => )
echo $test->aaa;//打印結果:aaa
復制代碼 代碼如下:
<?php
class test{
    private $name;
    private $sex;
    function __construct(){
        $this->aaa='aaa';
    }
}
$test=new test();
$reflect=new ReflectionObject($test);
$pro=$reflect->getProperties();
print_r($pro);
 
新聞熱點
疑難解答