Home :: International :: Manuals :: Howto :: FAQ :: Man Pages :: Email Login

 
 

 

call_user_func

(PHP 3>= 3.0.3, PHP 4 , PHP 5)

call_user_func --  最初の引数で指定したユーザ関数をコールする

説明

mixed call_user_func ( callback function [, mixed parameter [, mixed ...]])

パラメータ functionで指定したユーザ定義のコールバック関数 をコールします。以下のように行います。

<?php
function barber($type)
{
    echo
"You wanted a $type haircut, no problem";
}
call_user_func('barber', "mushroom");
call_user_func('barber', "shave");
?>

この関数のパラメータfunctionarray($objectname, $methodname)を指定することにより、 オブジェクトのメソッドも静的にコールすることができます。

<?php
class myclass {
  function
say_hello()
  {
    echo
"Hello!\n";
  }
}

$classname = "myclass";

call_user_func(array($classname, 'say_hello'));
?>

is_callable()および call_user_func_array()も参照して下さい。

 
 
 
 
Google
  Web Linuxinfor   
 

Home :: Copyright :: Privacy :: Credits :: Get a free Linuxinfor Email Account

Document on this page is part of "PHP マニュアル". See Index Page for more info about Authorship and Copyright.

1999-2009 Linuxinfor.com. No rights reserved.