Php-function-get-class-methods

提供:Dev Guides
移動先:案内検索

PHP-関数get_class_methods()

構文

get_method ( $class_name );

定義と使い方

クラスメソッド名を取得します。 class_nameで指定されたクラスに定義されたメソッド名の配列を返します。 エラーの場合、NULLを返します。

パラメーター

Sr.No Parameter & Description
1

class_name(Required)

クラス名

戻り値

class_nameで指定されたクラスに定義されたメソッド名の配列を返します。 エラーの場合、NULLを返します。

以下は、この機能の使用法です-

<?php
   class HelloWorld {
      function HelloWorld() {
         return(true);
      }

      function myfunc1() {
         return(true);
      }

      function myfunc2() {
         return(true);
      }
   }

   $method = get_method('HelloWorld');
   $method = get_method(new HelloWorld());

   foreach ($method as $method_name) {
      echo "$method_name \n";
   }
?>

それは次の結果を生成します-

HelloWorld
myfunc1
myfunc2