phpclass/클래스활용2000. 10. 10. 14:22
호환성
PHP4 >= 4.0RC1
기능
메소드명 반환 함수, 클래스 메소드명을 배열에 담아 반환
형식
array get_class_methods (string class_name)
설명
get_class_methods()는 클래스에 정의된 메소드명을 배열에 담아서 되돌려 줍니다. 상속되어 정의된 클래스의 경우는 상위클래스에 정의된 메소드명을 모두 포함합니다. 아래에 예제 코드와 실행 결과가 있습니다.
[code php;gutter:false] <?php

class Cart {
var $items; // Items in our shopping cart

// Add $num articles of $artnr to the cart

function add_item ($artnr, $num) {
$this->items[$artnr] += $num;
}

// Take $num articles of $artnr out of the cart

function remove_item ($artnr, $num) {
if ($this->items[$artnr] > $num) {
$this->items[$artnr] -= $num;
return true;
} else {
return false;
}
}
}

class Named_Cart extends Cart {
var $owner = "나 주인";

function set_owner ($name) {
$this->owner = $name;
}
}

$cart = new Named_Cart;
$cart->items = 200;

$aso = get_class_methods("Named_Cart");

while (list($k,$v)= each($aso)) {
echo("$aso[$k]=$v\n");
}

?> [/code]
< 예제 코드 >
$aso[0]=add_item
$aso[1]=remove_item
$aso[2]=set_owner
< 실행 결과 >
참고
get_class_vars(), get_object_vars()

Posted by 방글24