2017-09-25 43 views
1

我從php開始。我有一個DicomContainer容器,其中包含幾個功能。我想在我的WadoService服務中調用這些功能。在服務中使用容器功能

class DicomContainer { 

    /** 
    * Get Patient's Name. 
    * @return string Patient's Name. 
    */ 
    public function getPatientsName() { 
     //PatientsName 
     return $this->getValueOf("DICOM", "PatientsName"); 
    } 

} 

class WadoService { 
    $patientsname = getPatientName();??????? 

} 

這可能嗎?

回答

0

你的類DicomContainer應該被實例化使用的類WadoService其方法:

class WadoService { 

    public function someFunc() 
    { 
     $container = new DicomContainer(); 
     $patientsname = $container->getPatientsName(); 
    } 

} 
0

你不能在你的默認值調用functtion,但你可以在每一個類中使用__construct()方法調用進行初始化。

+0

對不起。但你怎麼能這樣呢? '公共函數__construct($ em){}' – Floriane

+0

是的,您有權利 – Amaury

+0

但我在大括號之間寫什麼? – Floriane