PHP反射

newInstanceArgs(array()); // 相当于实例化Person 类 //$instance->getName(); // 执行Person 里的方法getName // 或者: $method = $class->getmethod($a); // 获取Person 类中的getName方法 // supposing the extension defined something like: // Some_Class::someMethod($a, $x, $y, $x, $y) $p = new ReflectionParameter(array($c, $a), 0); //Echo the type of the parameter //echo $p->getClass()->name; $pclass= $p->getClass(); $pinstance= $pclass->newInstanceArgs(array()); echo $pclass->name; $pubic_properties = $pclass->getProperties(ReflectionProperty::IS_PUBLIC); foreach ($pubic_properties as $property) { //echo $property->name; $ps= $_REQUEST[$property->name]; $property->setValue($pinstance,$ps); } $method->invoke($instance,$pinstance); // 执行getName 方法 // returns the last parameter, whereas //$p = new ReflectionParameter(array('Some_Class', 'someMethod'), 'y'); // 或者:// $method = $class->getmethod('setName'); // 获取Person 类中的setName方法// $method->invokeArgs($instance, array('snsgou.com')); // require_once $c+".php"; //echo ""// echo $c;// echo $a;?>

你可能感兴趣的:(PHP,Php)