您的位置:首页 > 其它

将数据写入TXT文件中,file_put_contents与fwrite

2016-02-14 17:30 483 查看
<?php
header("content-type:text/html;charset=utf-8");

$file = './aa.txt';
###判断是不是文件
if(is_file($file)){
####判断是不是可写
if(is_writable($file)){
// echo "yes";
###判断文件是不是可读
if(false !== ($handle=fopen($file,'a'))){
// echo 1;
###执行写入操作
$content="56789 \r\n";

// file_put_contents($file,$content,FILE_APPEND); //用于装载执行失败的数据
fwrite($handle,$content);  ###效果同上

fclose($handle);
}else{
echo "no open";
}

}else{
echo "no write!";
}

}else{
echo "no file";
}

?>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: