if(false == ($handle = fopen($filename, 'a'))){
echo "文件 $filename 打开失败";
exit();
}
//将$content写入打开的文件
if(fwrite($handle, $content) === false){
echo "
php写入文件例子2:
$filename = "Test\\file.txt";
$file = fopen($filename, "w"); //以写模式打开文件
fwrite($file, "Hello, world!\n"); //写入第一行
fwrite($file, "This is a test!\n"); //写入第二行
fclose($file); //关闭文件
?>
删除文件:
$filename = "Test\\file.txt";
unlink($filename); //删除文件
?>
复制文件:
$filename1 = "Test\\file.txt";
$filename2 = "Test\\file.bak";
copy($filename1, $filename2); //复制文件
?>