"PHP call user func array()"의 두 판 사이의 차이

8번째 줄: 8번째 줄:
     echo __FUNCTION__, " got $arg and $arg2\n";
     echo __FUNCTION__, " got $arg and $arg2\n";
}
}
# foobar() 함수 호출
call_user_func_array("foobar", ['one', 'two']);
call_user_func_array("foobar", ['one', 'two']);
</syntaxhighlight>
</syntaxhighlight>
15번째 줄: 17번째 줄:
}
}


// $foo->bar() 메소드 호출
# $foo->bar() 메소드 호출
$foo = new foo;
$foo = new foo;
call_user_func_array([$foo, 'bar'], ['three', 'four']);
call_user_func_array([$foo, 'bar'], ['three', 'four']);

2021년 7월 18일 (일) 14:52 판

1 개요

PHP call_user_func_array()
  • 파라미터 배열로 콜백함수를 호출하는 PHP 함수
function foobar($arg, $arg2) {
    echo __FUNCTION__, " got $arg and $arg2\n";
}

# foobar() 함수 호출
call_user_func_array("foobar", ['one', 'two']);
function foobar($arg, $arg2) {
    echo __FUNCTION__, " got $arg and $arg2\n";
}

# $foo->bar() 메소드 호출
$foo = new foo;
call_user_func_array([$foo, 'bar'], ['three', 'four']);

2 같이 보기

3 참고

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}