저는 상속에 약간의 문제가 있습니다. 그클래스가 상속되지 않습니다. - 클래스를 찾을 수 없습니다.
파일 해서, A.php
namespace Main;
class A{
public function __construct(){ echo 'A->__construct'; }
}
같은 것을 가지고 B.php
namespace Main;
class B extends \Main\A{
/* if I write this construct and remove extends from this class - it works - but I need to inherit it */
public function __construct(){ $a = new \Main\A(); }
public function something(){ echo 'B->something';}
}
클래스가있는 경우를 상속 될 수 없습니다 않은 파일 또는 다른 클래스를 상속 ?
포함 했습니까? – MightyPork
A와 B 모두 같은 이름 공간 내에서 정의되었으므로 '클래스 B는 A 확장'을해야합니다. – Orangepill
@MightyPork 예 .. 필요하지 않은 경우 B-> 인스턴스를 만들지 않았습니다. __construct – StellaireMan