189 8069 5689

php创建文件

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

分享文章:php创建文件
网址分享:http://cdxtjz.cn/article/pdpood.html

其他资讯