mirror of
https://github.com/php/doc-ja.git
synced 2026-03-31 03:22:07 +02:00
git-svn-id: https://svn.php.net/repository/phpdoc/ja/trunk@185798 c90b9560-bf6c-de11-be94-00142212c4b1
96 lines
2.9 KiB
XML
96 lines
2.9 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision: 1.7 $ -->
|
|
<!-- EN-Revision: 1.10 Maintainer: hirokawa Status: ready -->
|
|
<!-- CREDITS: shimooka -->
|
|
<refentry id="function.call-user-method">
|
|
<refnamediv>
|
|
<refname>call_user_method</refname>
|
|
<refpurpose>
|
|
指定したオブジェクトのユーザーメソッドをコールする[古い関数]
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>説明</title>
|
|
<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>
|
|
PHP 4.1.0以降、<function>call_user_method</function>関数は古い関数
|
|
となっています。代わりに<literal>array(&$obj,
|
|
"method_name")</literal>構文を指定して
|
|
<function>call_user_func</function>等を使用してください。
|
|
</para>
|
|
</warning>
|
|
<para>
|
|
ユーザ定義のオブジェクト<parameter>obj</parameter>から
|
|
<parameter>method_name</parameter>により参照されるメソッドをコー
|
|
ルします。以下に使用例を示します。ここでは、クラスを定義し、オブ
|
|
ジェクトのインスタンスを作成し、
|
|
<function>call_user_method</function>を用いて、間接的に
|
|
そのクラスのメソッド<varname>print_info</varname>をコールします。
|
|
<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>
|
|
<function>call_user_func_array</function>,
|
|
<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
|
|
-->
|