runkit7_method_copy
(PECL runkit7 >= Unknown)
runkit7_method_copy — 클래스에서 다른 클래스로 메소드 복사
설명
runkit7_method_copy( string $destination_class, string $destination_method_name, string $source_class, string $source_method_name = ? ): bool
매개변수
destination_class
- 복사된 메서드의 대상 클래스
destination_method_name
- 대상 메서드 이름
source_class
- 복사할 메서드의 소스 클래스
source_method_name
- 소스 클래스에서 복사할 메서드의 이름입니다. 이 매개변수가 생략되면
destination_method_name
값이 가정됩니다.
반환 값
Examples
예제 #1 runkit7_method_copy() 예제
<?php
class Foo {
function example() {
return "foo!\n";
}
}
class Bar {
// initially, no methods
}
// copy the example() method from the Foo class to the Bar class, as baz()
runkit7_method_copy('Bar', 'baz', 'Foo', 'example');
// output copied function
echo Bar::baz();
?>
위의 예는 다음을 출력합니다.
foo!
기타
- runkit7_method_add() - 주어진 클래스에 새로운 메소드를 동적으로 추가
- runkit7_method_redefine() - 주어진 메소드의 코드를 동적으로 변경
- runkit7_method_remove() - 주어진 메소드를 동적으로 제거
- runkit7_method_rename() - 주어진 메소드의 이름을 동적으로 변경
- runkit7_function_copy() - 함수를 새 함수 이름으로 복사