PHP | ReflectionMethod getDeclaringClass() Function Last Updated : 28 Nov, 2019 Comments Improve Suggest changes Like Article Like Report The ReflectionMethod::getDeclaringClass() function is an inbuilt function in PHP which is utilized to return the name of the declared class. Syntax: ReflectionClass ReflectionMethod::getDeclaringClass ( void ) Parameters: This function does not accepts any parameter. Return Value: This function returns the name of the declared class for the reflected method. Below programs illustrates the ReflectionMethod::getDeclaringClass() function: Program 1: php <?php // Declaring a class class GeeksforGeeks { // Declaring a protected function protected function CSportal($name) { // Displays output return 'Geeks ' . $name; } } // Creating an object of ReflectionMethod $reflectionMethod = new ReflectionMethod(new GeeksforGeeks(), 'CSportal'); // Calling getDeclaringClass function var_dump($reflectionMethod->getDeclaringClass()); ?> Output: object(ReflectionClass)#2 (1) { ["name"]=> string(13) "GeeksforGeeks" } Program 2: php <?php // Declaring a class class NidhiSingh { // Declaring a protected function protected function Author($name) { // Displays output return 'Nidhi ' . $name; } } // Creating an object of ReflectionMethod $reflectionMethod = new ReflectionMethod(new NidhiSingh(), 'Author'); // Calling getDeclaringClass function var_dump($reflectionMethod->getDeclaringClass()); ?> Output: object(ReflectionClass)#2 (1) { ["name"]=> string(10) "NidhiSingh" } Reference: https://www.php.net/manual/en/reflectionmethod.getdeclaringclass.php. Comment More infoAdvertise with us Next Article Interview Preparation For Software Developers N nidhi1352singh Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-Imagick Similar Reads Interview PreparationInterview Preparation For Software DevelopersMust Coding Questions - Company-wise Must Do Coding Questions - Topic-wiseCompany-wise Practice ProblemsCompany PreparationCompetitive ProgrammingSoftware Design-PatternsCompany-wise Interview ExperienceExperienced - Interview ExperiencesInternship - Interview ExperiencesPractice @GeeksforgeeksProblem of the DayTopic-wise PracticeDifficulty Level - SchoolDifficulty Level - BasicDifficulty Level - EasyDifficulty Level - MediumDifficulty Level - HardLeaderboard !!Explore More...Data StructuresArraysLinked ListStackQueueBinary TreeBinary Search TreeHeapHashingGraphAdvance Data StructuresMatrixStringAll Data StructuresAlgorithmsAnalysis of AlgorithmsSearching AlgorithmsSorting AlgorithmsPattern SearchingGeometric AlgorithmsMathematical AlgorithmsRandomized AlgorithmsGreedy AlgorithmsDynamic ProgrammingDivide & ConquerBacktrackingBranch & BoundAll AlgorithmsProgramming LanguagesCC++JavaPythonC#Go LangSQLPHPScalaPerlKotlinWeb TechnologiesHTMLCSSJavaScriptBootstrapTailwind CSSAngularJSReactJSjQueryNodeJSPHPWeb DesignWeb BrowserFile FormatsComputer Science SubjectsOperating SystemsDBMSComputer NetworkComputer Organization & ArchitectureTOCCompiler DesignDigital Elec. & Logic DesignSoftware EngineeringEngineering MathematicsData Science & MLComplete Data Science CourseData Science TutorialMachine Learning TutorialDeep Learning TutorialNLP TutorialMachine Learning ProjectsData Analysis TutorialTutorial LibraryPython TutorialDjango TutorialPandas TutorialKivy TutorialTkinter TutorialOpenCV TutorialSelenium TutorialGATE CSGATE CS NotesGate CornerPrevious Year GATE PapersLast Minute Notes (LMNs)Important Topic For GATE CSGATE CoursePrevious Year Paper: CS exams Like