<?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']]);
用类的反射获取 父类的私有属性方法