Return value of function_name; if function_name is not a valid function name, the function generates a warning and no value is returned.
call_user_func_array() is primarily useful as a way to dynamically call functions and methods at runtime without having to use eval() . call_user_func_array() passes the elements in argument_array to function_name as an argument list. This makes it easy to pass an unknown number of arguments to a function. See the example for details.
Normally, functions are called with the following syntax:
function_name ('arg one', 'arg two', ...);
Calling the same function using call_user_func_array() would look like this:
call_user_func_array ('function_name', array ('arg one', 'arg two', ...));
The function name is somewhat of a misnomer - any PHP function can be called using this function. Watch out for language constructs like print() , echo() , unset() , etc. Attempts to call these constructs using this function will generate a warning.
To call a method using this function, use the following syntax:
$result = call_user_func_array (array (&$object, 'method'), array ($arg1, $arg2, ...));
To pass a variable number of arguments to a function (or method):
PHP Functions Essential Reference. Copyright © 2002 by New Riders Publishing (Authors: Zak Greant, Graeme Merrall, Torben Wilson, Brett Michlitsch). This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at http://www.opencontent.org/openpub/). The authors of this book have elected not to choose any options under the OPL. This online book was obtained from http://www.fooassociates.com/phpfer/ and is designed to provide information about the PHP programming language, focusing on PHP version 4.0.4 for the most part. The information is provided on an as-is basis, and no warranty or fitness is implied. All persons and entities shall have neither liability nor responsibility to any person or entity with respect to any loss or damage arising from the information contained in this book.