Functions Flashcards

1
Q

What type of function Returns the number of arguments passed to the function?

A

. func_num_args ( void )

Gets the number of arguments passed to the function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What function will return an item from the arguments list ?

A

func_get_arg ( int $arg_num )
Gets the specified argument from a user-defined function’s argument list.

This function may be used in conjunction with func_get_args() and func_num_args() to allow user-defined functions to accept variable-length argument lists.

Parameters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What function would you use to call an a static method?

A

forward_static_call ( callable $function [, mixed $parameter [, mixed $… ]] )

Calls a user defined function or method given by the function parameter, with the following arguments. This function must be called within a method context, it can’t be used outside a class. It uses the late static binding.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What function would you use to call static function that passes its arguments into an array ?

A

forward_static_call_array ( callable $function , array $parameters )

Calls a user defined function or method given by the function parameter.

This function must be called within a method context, it can’t be used outside a class. It uses the late static binding. All arguments of the forwarded method are passed as values, and as an array, similarly to call_user_func_array().

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What function returns the return value of the callback?

A

call_user_func ( callable $callback [, mixed $parameter [, mixed $… ]] )

Calls the callback given by the first parameter and passes the remaining parameters as arguments.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is session_destroy ?

A

session_destroy — Destroys all data registered to a session

Description

bool session_destroy ( void )
session_destroy() destroys all of the data associated with the current session. It does not unset any of the global variables associated with the session, or unset the session cookie. To use the session variables again, session_start() has to be called.

Returns TRUE on success or FALSE on failure.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
What must you look out for when passing default value as an argument in function like this
 function get( $type= ' go home' , $result ) {

Echo “ the result is” . $type . $result ;

}

A
When using default arguments, any defaults should be on the right side of any non-default arguments; otherwise, things will not work as expected.
function get( $result , $type= "go home"  ) {

Echo “ the result is” . $type . $result ;

}

The default value must be a constant expression, not (for example) a variable, a class member or a function call.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly