call_user_method

(PHP 3>= 3.0.3, PHP 4 )

call_user_method --  주어진 객체의 사용자 메소드(멤버함수)를 호출합니다.

Description

mixed call_user_method ( string method_name, object obj [, mixed parameter [, mixed ...]])

사용자가 정의한 obj 객체의 method_name 메소드를 호출합니다. 사용방법은 아래와 같습니다. 클래스를 정의한 후에 객체를 생성하고 call_user_method() 함수를 호출하여 print_info 메소드를 간접 호출합니다.

<?php
class Country {
    var $NAME;
    var $TLD;
    
    function Country($name, $tld) {
        $this->NAME = $name;
        $this->TLD = $tld;
    }

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

$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 ("print_info", $cntry, "\t");
?>

call_user_func()함수를 참고하세요.