class_implements — 지정된 클래스 또는 인터페이스에 의해 구현되는 인터페이스를 돌려줍니다. > 개발자팁

개발자팁

개발과 관련된 유용한 정보를 공유하세요.
질문은 QA에서 해주시기 바랍니다.

class_implements — 지정된 클래스 또는 인터페이스에 의해 구현되는 인터페이스를 돌려줍니다. 정보

PHP class_implements — 지정된 클래스 또는 인터페이스에 의해 구현되는 인터페이스를 돌려줍니다.

본문

class_implements — 지정된 클래스 또는 인터페이스에 의해 구현되는 인터페이스를 돌려줍니다.

 

설명 :

array class_implements ( mixed $class [, bool $autoload = true ] )

이 함수는 주어진 클래스와 부모가 구현하는 인터페이스의 이름을 가진 배열을 반환합니다.

 

인수 :

class

객체 (클래스 인스턴스) 또는 문자열 (클래스 또는 인터페이스 이름)입니다.

 

autoload

이 함수가 자동으로 __autoload () 매직 메소드를 통해 클래스를로드하도록 허용할지 여부.

 

반환값 :

성공하면 배열을, 오류가 발생하면 FALSE를 반환합니다.

 

 

Example #1 class_implements() example

 

<?php

 

interface foo { }

class bar implements foo {}

 

print_r(class_implements(new bar));

 

// since PHP 5.1.0 you may also specify the parameter as a string

print_r(class_implements('bar'));

 

 

function __autoload($class_name) {

   require_once $class_name . '.php';

}

 

// use __autoload to load the 'not_loaded' class

print_r(class_implements('not_loaded', true));

 

?>

위 예제의 출력 예시:

 

Array

(

    [foo] => foo

)

 

Array

(

    [interface_of_not_loaded] => interface_of_not_loaded

)

추천
1
  • 복사

댓글 0개

© SIRSOFT
현재 페이지 제일 처음으로