我正在尝试根据用户的电子邮件地址创建3个文件夹。我有一个主文件夹,然后是以电子邮件地址命名的文件夹,最后是一个名为images或tracks或chains的文件夹。我将路径传递给应该创建它们的函数。然而,一切都没有发生。你能告诉我我做错了什么吗?
public function createFolder($email){
$this->email=$email;
$this->pictureDirectoryPath = "../Uploads/$this->email/images";
$this->uploadedTracksPath = "../Uploads/$this->email/tracks";
$this->chainsPath = "../Uploads/$this->email/chains";
//Calling the function doIt(path) to create the acutal directory.
//The desired path is passed as a parameter
doIt($this->pictureDirectoryPath);
doIt($this->uploadedTracksPath);
doIt($this->chainsPath);
}
//Function doIt() which is supposed to create a directory
//However, nothing happens when it is called..
public function doIt($path){
if (!mkdir($path, 0777, true)) {
die('Failed to create folders...');
}
}
答案 0 :(得分:2)
要调用类中的函数/方法,您需要添加$this->
或self::
,具体取决于它是否为静态。
$this->doIt($this->pictureDirectoryPath);
$this->doIt($this->uploadedTracksPath);
$this->doIt($this->chainsPath);