PHP 类的反射

时间:2019-06-14 15:29:26   收藏:0   阅读:158
<?php
header("Content-Type:text/html;charset=utf-8");
class Baiduqq {

public static $name = "baiduzhidao";

static private function ask($name) {
echo "hello world".$name;
}

}

$refclass = new ReflectionClass("Baiduqq");
$properties_arr = $refclass->getdefaultproperties();
$method = $refclass->getMethod("ask");
if ($method->isPrivate()) {
$method->setAccessible(true);
}
$instance = $refclass->newInstance();
$method->invokeArgs($instance,["name"=>$properties_arr[name]]);

用类的反射获取 父类的私有属性方法

原文:https://www.cnblogs.com/blts/p/11023308.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!