请输入您要查询的百科知识:

 

词条 call_user_method
释义

call_user_method

(PHP 3 >= 3.0.3, PHP 4, PHP 5)call_user_method -- 对特定对象调用用户方法

说明

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 . "\";

echo $prestr . "Top Level Domain: " . $this->TLD . "\";

}

}

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

echo "* Calling the object method directly\";

$cntry->print_info();

echo "\* Calling the same method indirectly\";

call_user_method("print_info", $cntry, "\\t");

?>

随便看

 

百科全书收录4421916条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。

 

Copyright © 2004-2023 Cnenc.net All Rights Reserved
更新时间:2025/2/5 23:33:39