Wednesday, July 3, 2024
HomeLanguagesPhpPHP | ReflectionClass getMethod() Function

PHP | ReflectionClass getMethod() Function

The ReflectionClass::getMethod() function is an inbuilt function in PHP which is used to return a ReflectionMethod for the specified class method.

Syntax:

ReflectionMethod ReflectionClass::getMethod ( string $name )

Parameters: This function accepts a parameter $name which is the method name.

Return Value: This function returns a ReflectionMethod for the specified class method.

Below program illustrate the ReflectionClass::getMethod() function in PHP:




<?php
  
// Using ReflectionClass over the inbuilt class
// 'ReflectionClass'
$class = new ReflectionClass('ReflectionClass');
  
// Calling the getMethod over the method named
// as 'getMethod'
$method = $class->getMethod('getMethod');
  
// Getting the ReflectionMethod for the specified
// inbuilt class method.
var_dump($method);
?>


Output:

object(ReflectionMethod)#2 (2) {
  ["name"]=>
  string(9) "getMethod"
  ["class"]=>
  string(15) "ReflectionClass"
}

Reference: https://www.php.net/manual/en/reflectionclass.getmethod.php

Nicole Veronica Rubhabha
Nicole Veronica Rubhabha
A highly competent and organized individual DotNet developer with a track record of architecting and developing web client-server applications. Recognized as a personable, dedicated performer who demonstrates innovation, communication, and teamwork to ensure quality and timely project completion. Expertise in C#, ASP.Net, MVC, LINQ, EF 6, Web Services, SQL Server, MySql, Web development,
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments