自定义类
<?php
namespace houze;
class Demo{
protected $str;
private function __construct($str){
$this->str = $str;
}
public function error($str){
echo $this->str;
echo $str;
}
}创建反射类
// 命名空间+类名称
$name = 'houze\Demo';
$class = new \ReflectionClass($name);实例化类
$function = $class->newInstance('success');调用方法
$function->error('no');得到结果
success
no