<?php
class a{
function f($a,$b){
return $a.$b;
}
}
$function = new ReflectionMethod('a','f');
var_dump($function->getParameters());//这两可以看到返回结果有2个参数$a,$b。$class = new ReflectionClass('redis');
var_dump($class->getMethods(ReflectionMethod::IS_PUBLIC));
$p=$class->getMethod('subscribe');
var_dump($p->getParameters());//返回结果是空,但调用时提示需要2个参数。
exit();
?>难道只能用于自定义的类和方法吗?

解决方案 »

  1.   

    关键是你的ReflectionClass里写的是什么!
      

  2.   

    就是在一个扩展中定义的类,你若怀疑我写错了,可以改成:
    <?php
    $class = new ReflectionClass('mysqli');//这个类大家都在使用吧
    var_dump($class->getMethods(ReflectionMethod::IS_PUBLIC));
    $p=$class->getMethod('connect');//它的connect方法也都用过吧?假设我还不了解找个方法有几个参数。我先获得它的参数信息怎么办?
    var_dump($p->getParameters());//返回结果是空
    exit();
    ?>
      

  3.   

    http://www.php.net/manual/en/intro.reflection.phpPlease note that certain parts of the internal API are missing the necessary code to work with the Reflection extension. E.g., an internal PHP class might be missing reflection data for properties. These few cases are considered bugs, however, so they should be discovered and fixed.----测试我的签名----
     其实就是不知道签个啥名.....
      

  4.   

    这个问题是个bug?目前有无解决办法?
      

  5.   

    已经测试php-5.3.3-2解决,有兴趣的朋友帮我测测php-5.2.16。这里谢过了。我等着各位朋友测过php-5.2.16之后才会立即结贴。
      

  6.   

    自己测了5.2.16也存在此bug,看来我在这支持大家升级php5.3.3了。