//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("非法文件名");}