fork download
  1. <?php
  2. class Test {
  3. public function Test1(int $number, string $str) { }
  4. public static function Test2(int $number, string $str) { }
  5. }
  6.  
  7. //get the information about a specific method.
  8. $rm = new ReflectionMethod('Test', 'Test2');
  9.  
  10. //get all parameter names and parameter types of the method.
  11. foreach ($rm->getParameters() as $parameter) {
  12. echo 'Name: '.$parameter->getName().' - Type: '.$parameter->getType()."\n";
  13. }
Success #stdin #stdout 0.03s 25964KB
stdin
Standard input is empty
stdout
Name: number - Type: int
Name: str - Type: string