/**
* person类
*
* @since 2016-10-16
* @author mingazi@163.com
*/
class person
{
public $name;
public $age;
public function __construct($name,$age)
{
$this->name = $name;
$this->age = $age;
}
public function setName($name= '')
{
$this->name = $name;
}
public function setAge($age='')
{
$this->age = $age;
}
public function getUserInfo()
{
$info = '姓名:'.$this->name;
$info .= ' 年龄:'.$this->age;
return $info;
}
}
$stu = new person('lily','22');
var_dump($stu);
$obj = new ReflectionClass('person'); // 参数是类名
Reflection::export($obj);
返回结果如下
// var_dump 返回结果
object(person)#1 (2) {
["name"]=>
string(4) "lily"
["age"]=>
string(2) "22"
}
// Reflection::export()返回结果
Class [ <user> class person ] {
@@ /tmp/2c4cc08f-49d3-4584-8c82-ae4b4baf1975/code 2-25
- Constants [0] {
}
- Static properties [0] {
}
- Static methods [0] {
}
- Properties [2] {
Property [ <default> public $name ]
Property [ <default> public $age ]
}
- Methods [4] {
Method [ <user, ctor> public method __construct ] {
@@ /tmp/2c4cc08f-49d3-4584-8c82-ae4b4baf1975/code 6 - 10
- Parameters [2] {
Parameter #0 [ <required> $name ]
Parameter #1 [ <required> $age ]
}
}
Method [ <user> public method setName ] {
@@ /tmp/2c4cc08f-49d3-4584-8c82-ae4b4baf1975/code 11 - 14
- Parameters [1] {
Parameter #0 [ <required> $name ]
}
}
Method [ <user> public method setAge ] {
@@ /tmp/2c4cc08f-49d3-4584-8c82-ae4b4baf1975/code 15 - 18
- Parameters [1] {
Parameter #0 [ <required> $age ]
}
}
Method [ <user> public method getUserInfo ] {
@@ /tmp/2c4cc08f-49d3-4584-8c82-ae4b4baf1975/code 19 - 24
}
}
}