Home > Backend Development > PHP Tutorial > Write a simple PHP folder creation code, _PHP tutorial

Write a simple PHP folder creation code, _PHP tutorial

WBOY
Release: 2016-07-13 10:10:11
Original
1102 people have browsed it

写一段简单的PHP建立文件夹代码,

主要先获取当前目录的路径,然后判断文件夹是否存在,不存在则创建。

<&#63;php

define('DIR_ROOT', str_replace('\\','/',dirname(__FILE__)));//获取当前文件物理路径
$tmp_file_path = DIR_ROOT.'/tmp/';//在根目录下增加tmp目录的路径
if(is_dir($tmp_file_path))
	echo "tmp文件夹存在!";
else
{
	mkdir($tmp_file_path, 0700);//如果不存在tmp目录,则建立
	echo "tmp文件夹不存在,尝试建立成功!<br>";//未检测建立是否成功
	echo "tmp目录为".$tmp_file_path;
}
&#63;>
Copy after login

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/938854.htmlTechArticle写一段简单的PHP建立文件夹代码, 主要先获取当前目录的路径,然后判断文件夹是否存在,不存在则创建。 phpdefine('DIR_ROOT', str_replace('\\...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template