php-doc-en/reference/classobj/functions/call-user-method.xml

95 lines
2.7 KiB
XML
Raw Normal View History

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.8 $ -->
<!-- splitted from ./en/functions/classobj.xml, last change in rev 1.4 -->
<refentry id="function.call-user-method">
<refnamediv>
<refname>call_user_method</refname>
<refpurpose>
Call a user method on an specific object [deprecated]
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>mixed</type><methodname>call_user_method</methodname>
<methodparam><type>string</type><parameter>method_name</parameter></methodparam>
<methodparam><type>object</type><parameter>obj</parameter></methodparam>
<methodparam choice="opt"><type>mixed</type><parameter>parameter</parameter></methodparam>
<methodparam choice="opt"><type>mixed</type><parameter>...</parameter></methodparam>
</methodsynopsis>
<warning>
<para>
The <function>call_user_method</function> function is deprecated
as of PHP 4.1.0, use the <function>call_user_func</function> variety
with the <literal>array(&amp;$obj, "method_name")</literal> syntax instead.
</para>
</warning>
<para>
Calls 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.
</para>
<para>
<informalexample>
<programlisting role="php">
<![CDATA[
<?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_array</function>, and
<function>call_user_func</function>.
</simpara>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->