call_user_method

(PHP 3>= 3.0.3, PHP 4 >= 4.0.0)

call_user_method --  Zavolat u╛ivatelsky definouvanou metodu urΦitΘho objektu

Popis

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

Zavolß metodu method_name objektu obj. Ukßzka vyu╛itφ je nφ╛e, kde definujeme t°φdu, vytvo°φme objekt a pou╛ijeme call_user_method() k nep°φmΘmu volßnφ jejφ print_info metody.

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

Viz takΘ call_user_func().