码迷,mamicode.com
首页 > Web开发 > 详细

PHP 关于回调的用法

时间:2015-12-03 11:46:47      阅读:116      评论:0      收藏:0      [点我收藏+]

标签:

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);

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

PHP 关于回调的用法

标签:

原文地址:http://www.cnblogs.com/dhf327/p/5015421.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!