如果我有一组功能
private function create() { echo "create...."; }
private function read() { echo "read...."; }
private function edit() { echo "edit...."; }
..
以及如何使用
if(is_callable($this,"create")) {
call_user_func(array($this, "createe"), 'Hello World');
} else {
echo "not found";
}
此外,如果我有一组静态函数
private static function create() { echo "create...."; }
private static function read() { echo "read...."; }
private static function edit() { echo "edit...."; }
..
如何使用此变体?
if(functon_exists("self::create")) {
call_user_func(array($this, "createe"), 'Hello World');
} else {
echo "not found";
}
由于
答案 0 :(得分:0)
对于静态功能,请使用:
call_user_func(array('NameOfClass', 'create'));
或
call_user_func(array(get_class(), 'create'));