[ Index ] |
|
Code source de GeekLog 1.4.1 |
1 <?php 2 // +----------------------------------------------------------------------+ 3 // | PHP Version 4 | 4 // +----------------------------------------------------------------------+ 5 // | Copyright (c) 1997-2004 The PHP Group | 6 // +----------------------------------------------------------------------+ 7 // | This source file is subject to version 3.0 of the PHP license, | 8 // | that is bundled with this package in the file LICENSE, and is | 9 // | available at through the world-wide-web at | 10 // | http://www.php.net/license/3_0.txt. | 11 // | If you did not receive a copy of the PHP license and are unable to | 12 // | obtain it through the world-wide-web, please send a note to | 13 // | license@php.net so we can mail you a copy immediately. | 14 // +----------------------------------------------------------------------+ 15 // | Authors: Aidan Lister <aidan@php.net> | 16 // +----------------------------------------------------------------------+ 17 // 18 // $Id: call_user_func_array.php,v 1.13 2005/01/26 04:55:13 aidan Exp $ 19 20 21 /** 22 * Replace call_user_func_array() 23 * 24 * @category PHP 25 * @package PHP_Compat 26 * @link http://php.net/function.call_user_func_array 27 * @author Aidan Lister <aidan@php.net> 28 * @version $Revision: 1.13 $ 29 * @since PHP 4.0.4 30 * @require PHP 4.0.0 (user_error) 31 */ 32 if (!function_exists('call_user_func_array')) { 33 function call_user_func_array($function, $param_arr) 34 { 35 $param_arr = array_values((array) $param_arr); 36 37 // Sanity check 38 if (!is_callable($function)) { 39 if (is_array($function) && count($function) > 2) { 40 $function = $function[0] . '::' . $function[1]; 41 } 42 $error = sprintf('call_user_func_array() First argument is expected ' . 43 'to be a valid callback, \'%s\' was given', $function); 44 user_error($error, E_USER_WARNING); 45 return; 46 } 47 48 // Build argument string 49 $arg_string = ''; 50 $comma = ''; 51 for ($i = 0, $x = count($param_arr); $i < $x; $i++) { 52 $arg_string .= $comma . "\$param_arr[$i]"; 53 $comma = ', '; 54 } 55 56 // Determine method of calling function 57 if (is_array($function)) { 58 $object =& $function[0]; 59 $method = $function[1]; 60 61 // Static vs method call 62 if (is_string($function[0])) { 63 eval("\$retval = $object::\$method($arg_string);"); 64 } else { 65 eval("\$retval = \$object->\$method($arg_string);"); 66 } 67 } else { 68 eval("\$retval = \$function($arg_string);"); 69 } 70 71 return $retval; 72 } 73 } 74 75 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Wed Nov 21 12:27:40 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |