具體看:http://www.w3school.com.cn/php/func_filesystem_fopen.asp
列子:
$fopen = 'text.txt';
$str ='寫入一段文件www.51cto.com';
if( file_exists( $fopen ) )
{
$h = fopen($fopen,'a+');
if( fwrite($h,$str) )
{
echo '內容增加成功';
}
fclose($h);
}
else
{
$h = fopen( $fopen,'w+');
if( fwrite($h,$str))
{
echo '文件寫入成功';
}
fclose($h);
};