如果不存在,创建递归目录: [pre] /** * This function creates recursive directories if it doesn't already exist * * @param String The path that should be created * * @return void */ public function create_dirs($path) { if (!is_dir($path)) { $directory_path = ""; $directories = explode("/",$path); array_pop($directories); foreach($directories as $directory) { $directory_path .= $directory."/"; if (!is_dir($directory_path)) { mkdir($directory_path); chmod($directory_path, 0777); } } } } [/pre]