PHP 关于回调的用法

class aClass {

    public static function directWrite($message) {
        echo 'this is a static function from aClass !';
        echo "\n";
        echo $message;
        echo "\n";
    }

    function write($message) {
        echo 'this is a normal function from aClass !';
        echo "\n";
        echo $message;
        echo "\n";
    }

}

function test($echo)
{
    echo 'this is a single global function !';
    echo $echo, "\n";
}

$params = array("hello world ! all of you ");
$param='hello world ! just you ';

$method='test';

echo "\n ";
call_user_func_array($method, $params);


echo "\n ";
$method($param);


echo "\n ";
call_user_func_array(array('aClass', "directWrite"), $params);

$obj = new aClass();
$method='write';


echo "\n ";
call_user_func_array(array($obj, $method), $params);


echo "\n ";
$obj->{$method}($param);

一切不解释,直接上代码,不明白的概念自己查资料

posted @ 2015-12-03 10:54  心如止水-杜  阅读(365)  评论(0编辑  收藏  举报
技术文章,欢迎转载,转载请注明出处。 杜鹤飞的技术博客 邮箱地址:dhf327@163.com