phpclass/클래스활용2000. 10. 10. 14:17
호환성
PHP4 >= 4.0.5
기능
특정 객체에 포함된 사용자 정의 메소드 호출
형식
mixed call_user_method_array (string method_name, object obj [, array paramarr])
설명
사용자 정의 객체인 obj로부터 method_name으로 참조되는 해당 메소드를 호출합니다. call_user_method()가 메소드의 인수를 가변인수리스트 방식으로 전달하는데 반하여 call_user_method_array()는 배열 구조로 전달하는 것이 다릅니다. 아래에 있는 활용 예제에서 클래스를 정의하고, 객체를 인스턴스화하고, print_info 메소드를 간접적으로 호출하기 위해 call_user_method_array()를 이용합니다.
[code php;gutter:false] <?php

class Country {
var $NAME;
var $TLD;

function Country($name, $tld) {
$this->NAME = $name;
$this->TLD = $tld;
}

function print_info($prestr="", $poststr="") {
echo $prestr."Country: ".$this->NAME.$poststr;
echo $prestr."Top Level Domain: ".$this->TLD.$poststr;
}
}

$cntry = new Country("Peru","pe");

echo "* Calling the object method directly\n";
$cntry->print_info();

echo "\n* Calling the same method indirectly\n";
call_user_method_array("print_info", $cntry, array("\t", "\n"));

?> [/code]
참고
call_user_func_array(), call_user_func(), call_user_method()

Posted by 방글24