Developers Archive for the 'php function explanations' Category

call_user_func

call_user_func Wednesday, February 14th, 2007

call_user_func

call_user_func
It Call a user function that given by the first parameter
This is one of the method for calling a user-defined function.

Syntax:

mixed call_user_func ( string function_name [, mixed parameter [, mixed …]])

It Call a user defined function given by the function_name in the first parameter.

Example:

function test(int x)
{
}
function test(int x,int y)
{
}

The above function can be called as
test(2);
test(3,4);

By using the call_user_func We call the above function as

call_user_func (’test’, 2);
call_user_func (’test’, 3,4);

here, both are calling the function test().

get_defined_functions

get_defined_functions Wednesday, January 24th, 2007

get_defined_functions

get_defined_functions
- It  returns an array of all defined functions

Syntax:

array get_defined_functions ( void)

This function returns an multidimensional array containing a list of all defined functions, both built-in (internal) and user-defined. The internal functions will be accessible via $arr[”internal”], and the user defined ones using $arr[”user”]

Example:

function sample()
{
return true;
}

$arr = get_defined_functions();

print_r($arr);

The result in $arr is

Array
(
[internal] => Array
(
[0] => zend_version
[1] => func_num_args
[2] => func_get_arg
[3] => func_get_args
[4] => strlen
[5] => strcmp
[6] => strncmp

[750] => bcscale
[751] => bccomp
)

[user] => Array
(
[0] => sample
)

)

Array shift function

Array shift function Tuesday, January 23rd, 2007

This function is used toshift an element off the beginning of array

Syntax:

mixed array_shift( array array)

Example:

$input = array (”user1″, “user2″, “user3″);

$output =array_shift($input);

The result when we print $input will be like

Array

(

[0] => user2

[1] => user3

)


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.