我正在尝试在 PHP 中获取类的属性
class Test(){
public function import($data) {
$im = new import($this, $data);
$im->getInfo();
$this->fileInfo = $im->getRecord();
new ImportData($this, $this->fileInfo);
return true;
}
public function getFilePath(){
return $this->fileInfo;
}
}
在我的另一个文件中。
$import = new Test();
$filePath = $import ->getFilePath();
//$filePath returns nothing becasue $this->fileInfo is not init yet.
//my other codes here.
//my other codes here.
//call import method here.
$import ->import($data);
我需要调用getFilePath
beforeimport
方法,但我只能获取$this->fileInfo
inimport
方法。反正这周围有吗?非常感谢!