Files
doc-fr/reference/classobj/functions/call-user-method.xml
Yannick Torres 76070910c1 sync with EN
git-svn-id: https://svn.php.net/repository/phpdoc/fr/trunk@172674 c90b9560-bf6c-de11-be94-00142212c4b1
2004-11-14 21:33:27 +00:00

96 lines
2.9 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.11 $ -->
<!-- EN-Revision: 1.10 Maintainer: dams Status: ready -->
<refentry id="function.call-user-method">
<refnamediv>
<refname>call_user_method</refname>
<refpurpose>
Appelle une méthode utilisateur d'un objet
</refpurpose>
</refnamediv>
<refsect1>
&reftitle.description;
<methodsynopsis>
<type>mixed</type><methodname>call_user_method</methodname>
<methodparam><type>string</type><parameter>method_name</parameter></methodparam>
<methodparam><type>object</type><parameter role="reference">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>
La fonction <function>call_user_method</function> est abandonnée depuis
&php; 4.1.0, utilisez plutôt la fonction <function>call_user_func</function>
avec la syntaxe <literal>array(&amp;$obj, "method_name")</literal>.
</para>
</warning>
<para>
<function>call_user_method</function> appelle la méthode
<parameter>method_name</parameter> de l'objet
<parameter>obj</parameter>, avec les paramètres
<parameter>parameter</parameter>, <parameter>...</parameter>.
Un exemple d'utilisation de cet objet
est présenté ci-dessous, où une classe est définie, puis instantiée.
On utilise alors <function>call_user_method</function> pour appeler
indirectement les méthodes <varname>print_info</varname>.
<example>
<title>Exemple avec <function>call_user_method</function></title>
<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."Pays : ".$this->NAME."\n";
echo $prestr."Top Level Domain : ".$this->TLD."\n";
}
}
$cntry = new Country("Perou","pe");
echo "* Appel de la méthode de l'objet directement\n";
$cntry->print_info();
echo "\n* Appel de la méthode de l'objet indirectement\n";
call_user_method ("print_info", $cntry, "\t");
?>
]]>
</programlisting>
</example>
</para>
<simpara>
Voir aussi
<function>call_user_func_array</function> et
<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
-->