if(!file_exists("12345.txt")){ //如果文件不存在(默认为当前目录下) $fh = fopen("12345.txt","w"); fwrite($fh, 'haha'); //在文件中写入haha fclose($fh); //关闭文件}