看板 PHP 關於我們 聯絡資訊
我有三個class A,B,BB BB繼承B 然後A裡面有一個method getB() 會回傳一個B的instance 也就是 class A{ private $b; public function __construct(){ $this->b= new B(); } public function getB(){ return $this->b; } } 假設$a = new A(); 請問我可以將 $a->getB()回傳的物件 轉換成BB的物件嗎? 我異想天開的試過$bb= (BB) $a->getB(); 但語法錯誤 請各位先進指導指導 甘溫~ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 210.202.81.67