首页 > Web开发 > 详细

PHP 类的反射

时间:2019-06-14 15:29:26      阅读:154      评论:0      收藏:0      [点我收藏+]
<?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]]);

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

PHP 类的反射

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!