//3.创建文件
$filename = $path."\\2.txt";
$pattern = "/[\/,\*,<>,\?\|]/";
if (!preg_match($pattern,$filename)) {
//判断同名文件是否存在
if (!file_exists($filename)) {
//touch($filename)创建文件
if (touch($filename)) {
print_r("创建成功");
}else{
print_r("创建失败");
}
}else{
print_r("文件已经存在,请重新命名");
}
}else{
print_r("非法文件名");
}本文出自 “素颜” 博客,请务必保留此出处http://suyanzhu.blog.51cto.com/8050189/1897426
原文:http://suyanzhu.blog.51cto.com/8050189/1897426