超越PHP PHP动态 | 经典文章 | CLASS | 相关下载 | 常见问题 | FORUM | WIKI | 在线手册
Site search:    
<Function handlingcall_user_func>
Last updated: Fri, 22 Jun 2007

call_user_func_array

(PHP 4 >= 4.0.4, PHP 5)

call_user_func_array --  Call a user function given with an array of parameters

Description

mixed call_user_func_array ( callback function, array param_arr)

Call a user defined function given by function, with the parameters in param_arr. For example:

例子 1. call_user_func_array() example

<?php
function debug($var, $val)
{
   echo
"***DEBUGGING\nVARIABLE: $var\nVALUE:";
   if (
is_array($val) || is_object($val) || is_resource($val)) {
      
print_r($val);
   } else {
       echo
"\n$val\n";
   }
   echo
"***\n";
}

$c = mysql_connect();
$host = $_SERVER["SERVER_NAME"];

call_user_func_array('debug', array("host", $host));
call_user_func_array('debug', array("c", $c));
call_user_func_array('debug', array("_POST", $_POST));
?>

See also call_user_func(), and information about the callback type




add a note add a note User Contributed Notes
call_user_func_array
NOSPAM dot dont dot remove at thekid dot de
23-Jun-2002 07:19
Unified constructors in PHP4:

<?php
 class Object {
  function Object() {
     $args= func_get_args();
    call_user_func_array(array(&$this, '__construct'), $args);
  }

   function __construct($args= NULL) {
    var_dump($args);
   }
 }

 class Exception extends Object {
   var
     $message;
     
   function __construct($message) {
     $this->message= $message;
    parent::__construct();
   }
 }

 class IOException extends Exception {
 }
 
 var_dump(
   error_reporting(),
  zend_version(),
   phpversion()
 );
 
 $c= new IOException('file not found');
 
 echo '===> Result: '; var_dump($c);
?>

<Function handlingcall_user_func>
 Last updated: Fri, 22 Jun 2007
view source | feedback | send page | sitemap | aboutus   
Copyright ® 2002-2003 PHPE.NET. All rights reserved
Last updated:2002-11-22