PHP | call_user_func() Function Last Updated : 25 Jun, 2018 Comments Improve Suggest changes Like Article Like Report The call_user_func() is an inbuilt function in PHP which is used to call the callback given by the first parameter and passes the remaining parameters as argument. It is used to call the user-defined functions. Syntax: mixed call_user_func ( $function_name[, mixed $value1[, mixed $... ]]) Here, mixed indicates that a parameter may accept multiple types. Parameter: The call_user_func() function accepts two types of parameters as mentioned above and described below: $function_name: It is the name of function call in the list of defined function. It is a string type parameter. $value: It is mixed value. One or more parameters to be passed to the function. Return Value: This function returns the value returned by the callback function. Below programs illustrate the call_user_func() function in PHP: Program 1: Call the function php <?php function GFG($value) { echo "This is $value site.\n"; } call_user_func('GFG', "GeeksforGeeks"); call_user_func('GFG', "Content"); ?> Output: This is GeeksforGeeks site. This is Content site. Program 2: call_user_func() using namespace name php <?php namespace Geeks; class GFG { static public function demo() { print "GeeksForGeeks\n"; } } call_user_func(__NAMESPACE__ .'\GFG::demo'); // Another way of declaration call_user_func(array(__NAMESPACE__ .'\GFG', 'demo')); ?> Output: GeeksForGeeks GeeksForGeeks Program 3: Using a class method with call_user_func() php <?php class GFG { static function show() { echo "Geeks\n"; } } $classname = "GFG"; call_user_func($classname .'::show'); // Another way to use object $obj = new GFG(); call_user_func(array($obj, 'show')); ?> Output: Geeks Geeks Program 4: Using lambda function with call_user_func() php <?php call_user_func(function($arg) { print "$arg\n"; }, 'GeeksforGeeks'); ?> Output: GeeksforGeeks References: http://php.net/manual/en/function.call-user-func.php Comment More infoAdvertise with us Next Article PHP | call_user_func() Function M Mithun Kumar Follow Improve Article Tags : Misc Web Technologies PHP PHP-function Practice Tags : Misc Similar Reads PHP class_uses() Function The class_uses() function is an inbuilt function in PHP where the traits utilized by the given class, will be returned. Syntax: class_uses($object_or_class,$autoload = true): array|false Parameters: This function accepts the two parameters that are described below object_or_class: The name of the cl 2 min read PHP get_current_user () Function The get_current_user() function is an inbuilt function in PHP that returns the owner of the current script. Syntax: string get_current_user()Parameters: This function does not accept any parameter. Return Value: This function returns the username of the current script in the string format. Example 1 1 min read PHP func_get_arg() Function The func_get_arg() function is an inbuilt function in PHP which is used to get a mentioned value from the argument passed as the parameters. Syntax: mixed func_get_arg( int $arg ) Parameters: This function accepts a single parameter as mentioned above and described below. $arg: This parameter holds 2 min read PHP create_function() Function The create_function() is an inbuilt function in PHP which is used to create an anonymous (lambda-style) function in the PHP. Syntax: string create_function ( $args, $code ) Parameters: This function accepts two parameters which is describes below: $args: It is a string type function argument. $code: 2 min read PHP | ftp_alloc() function The ftp_alloc() function is an inbuilt function in PHP which is used to allocate space for file to be uploaded in FTP server.Syntax:Â Â ftp_alloc( $ftp_connection, $filesize, $result ); Parameter: This function accepts three parameters as mentioned above and described below:Â Â $ftp_connection: It is 3 min read Like