在服务中使用容器功能

在服务中使用容器功能

问题描述:

I start in php. I have a DicomContainercontainer that contains several functions. I would like to call these functions in my WadoServiceservice.

class DicomContainer {

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

}

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

}

Is it possible ?

我从php开始。 我有一个包含多个函数的 DicomContainer code>容器。 我想在我的 WadoService code>服务中调用这些函数。 p>

  class DicomContainer {
 
 / ** 
 *获取患者姓名。  
 * @return string患者姓名。
 * / 
公共函数getPatientsName(){
 // PatientsName 
返回$ this-> getValueOf(“DICOM”,“PatientsName”); 
} 
  
} 
 
class WadoService {
 $ patientsname = getPatientName(); ??????? 
 
} 
  code>  pre> 
 
 

是否有可能 ? p> div>

Your class DicomContainer should be instantiated to use its methods on the WadoService class:

class WadoService {

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

}

You can't call a functtion in your default value but you can use the __construct() method call in every class for initialisation.