PHP | ReflectionMethod __toString() Function Last Updated : 23 Dec, 2019 Comments Improve Suggest changes Like Article Like Report The ReflectionMethod::__toString() function is an inbuilt function in PHP which is used to return the string representation of the specified method object. Syntax: string ReflectionMethod::__toString ( void ) Parameters: This function does not accept any parameter. Return Value: This function returns the string representation of the specified method object. Below programs illustrate the ReflectionMethod::__toString() function in PHP: Program 1: php <?php // Initializing a user-defined class class Company { function GFG() {} } // Using ReflectionMethod() over the class Company $A = new ReflectionMethod('Company', 'GFG'); // Calling the __toString() function $B = $A->__toString(); // Getting the string representation of // the specified method object 'GFG' var_dump($B); ?> Output: string(94) "Method [ <user> public method GFG ] { @@ /home/43d46426def0fce620e2e2cf2bf10e7a.php 6 - 6 } " Program 2: php <?php // Initializing some user-defined classes class Department1 { private function hr($name) { return 'HR' . $name; } } class Department2 { static function Coding() {} } class Department3 { protected function marketing(){} } // Using ReflectionMethod() over the above classes $A = new ReflectionMethod('Department1', 'hR'); $B = new ReflectionMethod('Department2', 'Coding'); $C = new ReflectionMethod('Department3', 'marketing'); // Calling the __toString() function and // getting the string representation of the // above method objects var_dump($A->__toString()); var_dump($B->__toString()); var_dump($C->__toString()); ?> Output: string(158) "Method [ <user> private method hr ] { @@ /home/2aa9608c9056b85288d53e96d9de3310.php 6 - 8 - Parameters [1] { Parameter #0 [ <required> $name ] } } " string(106) "Method [ <user> static public method Coding ] { @@ /home/2aa9608c9056b85288d53e96d9de3310.php 12 - 12 } " string(105) "Method [ <user> protected method marketing ] { @@ /home/2aa9608c9056b85288d53e96d9de3310.php 17 - 17 } " Reference: https://www.php.net/manual/en/reflectionmethod.tostring.php Comment More infoAdvertise with us Next Article PHP | ReflectionMethod __toString() Function K Kanchan_Ray Follow Improve Article Tags : Web Technologies PHP PHP-function PHP- Reflection Similar Reads PHP | ReflectionParameter __toString() Function The ReflectionParameter::__toString() function is an inbuilt function in PHP which is used to return the string form of the specified parameter. Syntax: string ReflectionParameter::__toString ( void ) Parameters: This function does not accept any parameters. Return Value: This function returns the s 2 min read PHP | ReflectionExtension __toString() Function The ReflectionExtension::__toString() function is an inbuilt function in PHP which is used to return the string representation of the specified extension object. Syntax: ReflectionExtension::__toString() Parameters: This function does not accept any parameter. Return Value: This function returns the 2 min read PHP | ReflectionFunction __toString() Function The ReflectionFunction::__toString() function is an inbuilt function in PHP which is used to return the string representation of the specified function.Syntax: string ReflectionFunction::__toString( void ) Parameters: This function does not accept any parameters.Return Value: This function returns t 2 min read PHP | ReflectionProperty __toString() Function The ReflectionProperty::__toString() function is an inbuilt function in PHP which is used to return the string form of the specified property. Syntax: public string ReflectionProperty::__toString ( void ) : string Parameters: This function does not accept any parameters. Return Value: This function 2 min read PHP | ReflectionMethod invoke() Function The ReflectionMethod::invoke() function is an inbuilt function in PHP which is used to invoke the specified reflected method and returns the result of the method.Syntax: public mixed ReflectionMethod::invoke ( $object, $parameter ) Parameters: This function accepts two parameters which are illustrat 2 min read PHP | ReflectionMethod export() Function The ReflectionMethod::export() function is an inbuilt function in PHP which is used to return the export as a string if the return parameter has been set to TRUE, otherwise NULL is returned. Syntax: string ReflectionMethod::export ( $class, $name, $return ) Parameters: This function accepts three pa 3 min read PHP | ReflectionMethod isFinal() Function The ReflectionMethod::isFinal() function is an inbuilt function in PHP which is used to return TRUE if the specified method is final, otherwise returns FALSE. Syntax: bool ReflectionMethod::isFinal( void ) Parameters: This function does not accept any parameters. Return Value: This function returns 2 min read PHP | ReflectionMethod isStatic() Function The ReflectionMethod::isStatic() function is an inbuilt function in PHP which is used to return TRUE if the specified method is static, otherwise FALSE. Syntax: public bool ReflectionMethod::isStatic ( void ) Parameters: This function does not accept any parameter. Return Value: This function return 2 min read PHP | ReflectionMethod isPublic() Function The ReflectionMethod::isPublic() function is an inbuilt function in PHP which is used to return TRUE if the specified method is public, otherwise FALSE. Syntax: bool ReflectionMethod::isPublic ( void ) Parameters: This function does not accept any parameter. Return Value: This function returns TRUE 2 min read PHP | ReflectionMethod isPrivate() Function The ReflectionMethod::isPrivate() function is an inbuilt function in PHP which is used to return TRUE if the specified method is private, otherwise returns FALSE. Syntax: bool ReflectionMethod::isPrivate( void ) Parameters: This function does not accept any parameters. Return Value: This function re 2 min read Like