User Tools

Site Tools


uphp:functions:call_user_func

call_user_func

WMPRO, WMMINI FW >= 1.0 WMMEGA FW >= 2.0

Call a user defined function with optional parameters

Description

mixed call_user_func ( string $function_name [, mixed $parameters ... ] )

Return result as defined by the user function

Parameters

$function_name: String containing the name of the user function to call

$parameters: Optional parameter(s) to pass to the function

Return Values

Mixed: Any type depending on the way the function is defined

Example

<?
  function my_add($x,$y) {
    return $x+$y;
  }
  $result=call_user_func("my_add",1,3);
  print($result); // result is 4
?>

See Also

function_exists() - Check if a function exists (native or custom)

function - Define a function

return - Return program control to the calling module

Additional Information

User defined functions can take many different forms, and it is not necessary to use call_user_func() to execute a function unless a direct return value is needed.

If used within a function, the return statement immediately ends execution of the function, and returns its argument as the value of the function call.

uphp/functions/call_user_func.txt · Last modified: 2021/09/13 05:57 (external edit)