PHP | ReflectionFunction __toString() Function Last Updated : 07 Feb, 2022 Comments Improve Suggest changes Like Article Like Report 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 the string representation of the specified function.Below programs illustrate the ReflectionFunction::__toString() function in PHP:Program 1: php <?php // Initializing a user-defined function function Company($Company_Name, $Role) { return sprintf("%s %s\r\n", $Company_Name, $Role); } // Using ReflectionFunction() over the specified // function company $function = new ReflectionFunction('company'); // Calling the __toString() function $A = $function->__toString(); // Getting the string representation of the // above specified function echo $A; ?> Output: Function [ <user> function Company ] { @@ /home/a39c30763ecfc7f257d02e44de746b22.php 4 - 7 - Parameters [2] { Parameter #0 [ <required> $Company_Name ] Parameter #1 [ <required> $Role ] } } Program 2: php <?php // Initializing some user-defined functions function Trial1($First_Args, $Second_Args) { return sprintf("%s %s\r\n", $First_Args, $Second_Args); } function Trial2($First_Args, $Second_Args) { return sprintf("%s %s\r\n", $First_Args, $Second_Args); } // Using ReflectionFunction() over the above // specified functions $function = new ReflectionFunction('Trial1'); $function = new ReflectionFunction('Trial2'); // Calling the __toString() function and // Getting string representation of the // above specified function echo $function->__toString(); echo $function->__toString(); ?> Output: Function [ <user> function Trial2 ] { @@ /home/09f598906ca0bfcad4613b5dea41c27b.php 9 - 12 - Parameters [2] { Parameter #0 [ <required> $First_Args ] Parameter #1 [ <required> $Second_Args ] } } Function [ <user> function Trial2 ] { @@ /home/09f598906ca0bfcad4613b5dea41c27b.php 9 - 12 - Parameters [2] { Parameter #0 [ <required> $First_Args ] Parameter #1 [ <required> $Second_Args ] } } Reference: https://www.php.net/manual/en/reflectionfunction.tostring.php Comment More infoAdvertise with us Next Article PHP | ReflectionFunction __toString() Function K Kanchan_Ray Follow Improve Article Tags : Web Technologies PHP PHP-function PHP- Reflection Similar Reads 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 | ReflectionMethod __toString() Function 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 return 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 | 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 | ReflectionFunction invoke() Function The ReflectionFunction::invoke() function is an inbuilt function in PHP which is used to return the result of the invoked function call. Syntax: mixed ReflectionFunction::invoke( mixed $args) Parameters: This function accept parameter $args which holds the list of arguments passed to the called func 2 min read PHP ReflectionFunction export() Function The ReflectionFunction::export() function is an inbuilt function in PHP which is used to return the export as a string if the return parameter is set to TRUE, otherwise NULL is returned. Syntax: string ReflectionFunction::export( string $name, string $return ) Parameters: This function accepts two p 2 min read PHP | ReflectionFunction invokeArgs() Function The ReflectionFunction::invokeArgs() function is an inbuilt function in PHP which is used to return the result of the invoked function call. Syntax: mixed ReflectionFunction::invokeArgs( array $args ) Parameters: This function accepts a single parameter $args which holds the array of arguments passe 2 min read PHP | ReflectionExtension info() Function The ReflectionExtension::info() function is an inbuilt function in PHP which is used to return the information of the specified extension. Syntax: void ReflectionExtension::info( void ) Parameters: This function does not accept any parameter. Return Value: This function returns the information of th 1 min read PHP | ReflectionExtension export() Function The ReflectionExtension::export() function is an inbuilt function in PHP which is used to return the export as a string if the return parameter is set to TRUE, otherwise NULL is returned. Syntax: string ReflectionExtension::export( string $name, string $return ) Parameters: This function accepts two 2 min read PHP | ReflectionExtension getName() Function The ReflectionExtension::getName() function is an inbuilt function in PHP which is used to return the name of the specified extension. Syntax: string ReflectionExtension::getName( void ) Parameters: This function does not accept any parameter. Return Value: This function returns the name of the spec 1 min read Like