mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 08:58:56 +00:00
moved call_user_method from var.xml to classobj.xml
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@29605 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
bdbcf5b50e
commit
c13ddb7992
2 changed files with 69 additions and 69 deletions
|
@ -388,6 +388,75 @@ Object leafy belongs to class spinach a subclass of Vegetable
|
|||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<refentry id="function.call-user-method">
|
||||
<refnamediv>
|
||||
<refname>call_user_method</refname>
|
||||
<refpurpose>
|
||||
Call a user method on an specific object
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>mixed
|
||||
<function>call_user_method</function>
|
||||
</funcdef>
|
||||
<paramdef>string
|
||||
<parameter>method_name</parameter>
|
||||
</paramdef>
|
||||
<paramdef>object
|
||||
<parameter>obj</parameter>
|
||||
</paramdef>
|
||||
<paramdef>mixed
|
||||
<parameter><optional>parameter</optional></parameter>
|
||||
</paramdef>
|
||||
<paramdef>mixed
|
||||
<parameter><optional>...</optional></parameter>
|
||||
</paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Calls a the method referred by <parameter>method_name</parameter> from
|
||||
the user defined <parameter>obj</parameter> object. An example of usage
|
||||
is below, where we define a class, instantiate an object and use
|
||||
<function>call_user_method</function> to call indirectly its
|
||||
<varname>print_info</varname> method.
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<?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");
|
||||
?>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
<simpara>
|
||||
See also <function>call_user_func</function>.
|
||||
</simpara>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
</reference>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -44,75 +44,6 @@ call_user_func ('barber', "shave");
|
|||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<refentry id="function.call-user-method">
|
||||
<refnamediv>
|
||||
<refname>call_user_method</refname>
|
||||
<refpurpose>
|
||||
Call a user method on an specific object
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>mixed
|
||||
<function>call_user_method</function>
|
||||
</funcdef>
|
||||
<paramdef>string
|
||||
<parameter>method_name</parameter>
|
||||
</paramdef>
|
||||
<paramdef>object
|
||||
<parameter>obj</parameter>
|
||||
</paramdef>
|
||||
<paramdef>mixed
|
||||
<parameter><optional>parameter</optional></parameter>
|
||||
</paramdef>
|
||||
<paramdef>mixed
|
||||
<parameter><optional>...</optional></parameter>
|
||||
</paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Calls a the method referred by <parameter>method_name</parameter> from
|
||||
the user defined <parameter>obj</parameter> object. An example of usage
|
||||
is below, where we define a class, instantiate an object and use
|
||||
<function>call_user_method</function> to call indirectly its
|
||||
<varname>print_info</varname> method.
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<?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");
|
||||
?>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
|
||||
|
||||
|
||||
<refentry id="function.doubleval">
|
||||
<refnamediv>
|
||||
<refname>doubleval</refname>
|
||||
|
|
Loading…
Reference in a new issue