在服务中使用容器功能
I start in php. I have a DicomContainer
container that contains several functions. I would like to call these functions in my WadoService
service.
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开始。 我有一个包含多个函数的 是否有可能 ? p>
div> DicomContainer code>容器。 我想在我的
WadoService code>服务中调用这些函数。 p>
class DicomContainer {
/ **
*获取患者姓名。
* @return string患者姓名。
* /
公共函数getPatientsName(){
// PatientsName
返回$ this-> getValueOf(“DICOM”,“PatientsName”);
}
}
class WadoService {
$ patientsname = getPatientName(); ???????
}
code> pre>
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.