<?php
class FirstClass{
public static $second;
public static $result = 'not this =/';
public function __construct(){
$this->result = 'ok';
$this->second = new SecondClass();
}
public function show(){
echo $this->second->value;
}
}
class SecondClass extends FirstClass{
public $value;
public function __construct(){
$this->value = parent::$result; //Make it get "ok" here
}
}
$temp = new FirstClass();
$temp->show(); //It will show: "not this =/"
?>
어떻게하면 "ok"를 인쇄 할 수 있습니까?PHP 클래스 - 클래스에 부모를 알려주는 값을 어떻게 만들 수 있습니까?
즉, SecondClass는 어떤 FirstClass가 결과로 설정했는지 알아야합니다.