Welcome Guest, Not a member yet? Register   Sign In
function call by getting the name of function from URL
#8

[eluser]Phil Sturgeon[/eluser]
Three ways to call a function from a variable name in PHP.

Option #1:

Code:
$this->{$function_name[1]}();

Option #2:

Code:
call_user_func(array($this, $function_name[1]), $param1, $param2, $param3);

Option #3:
$params = array( $param1, $param2, $param3 );
Code:
call_user_func_array(array($this, $function_name[1]), $params );


Messages In This Thread
function call by getting the name of function from URL - by El Forum - 06-16-2009, 01:18 AM
function call by getting the name of function from URL - by El Forum - 06-16-2009, 01:25 AM
function call by getting the name of function from URL - by El Forum - 06-16-2009, 02:51 AM
function call by getting the name of function from URL - by El Forum - 06-16-2009, 03:07 AM
function call by getting the name of function from URL - by El Forum - 06-18-2009, 08:16 AM
function call by getting the name of function from URL - by El Forum - 06-18-2009, 09:06 AM
function call by getting the name of function from URL - by El Forum - 06-18-2009, 09:21 AM
function call by getting the name of function from URL - by El Forum - 06-18-2009, 09:24 AM
function call by getting the name of function from URL - by El Forum - 06-18-2009, 09:24 AM
function call by getting the name of function from URL - by El Forum - 06-18-2009, 09:38 AM



Theme © iAndrew 2016 - Forum software by © MyBB