
PHP에서 Iterator 인터페이스를 상속받은 클래스를 생성할 때, 부모 클래스의 생성자 __construct() 함수를 호출하는 방법은 다음과 같습니다.
#hostingforum.kr
php
class 부모클래스 {
public function __construct() {
// 부모 클래스의 생성자 코드
}
}
class 자식클래스 extends 부모클래스 implements Iterator {
public function __construct() {
parent::__construct(); // 부모 클래스의 생성자 호출
}
}
parent::__construct() 함수를 사용하여 부모 클래스의 생성자 __construct() 함수를 호출할 수 있습니다.
2025-03-08 23:09