호환성
PHP4 >= 4.0RC1
기능
메소드명 반환 함수, 클래스 메소드명을 배열에 담아 반환
형식
array get_class_methods (string class_name)
설명
get_class_methods()는 클래스에 정의된 메소드명을 배열에 담아서 되돌려 줍니다. 상속되어 정의된 클래스의 경우는 상위클래스에 정의된 메소드명을 모두 포함합니다. 아래에 예제 코드와 실행 결과가 있습니다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
/** * 예제 코드 */ 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"); } |
- 실행 결과
1 2 3 |
$aso[0]=add_item $aso[1]=remove_item $aso[2]=set_owner |
참고
get_class_vars(), get_object_vars()