代码 --------------- dataStr="FMsg/".date("y-m-d");//获取当前日期作为文件夹名 $this->file_old="FMsg/... 代码
---------------
dataStr="FMsg/".date("y-m-d");//获取当前日期作为文件夹名
$this->file_old="FMsg/model.html";
$this->file_new=$this->dataStr."/pap1122.html";
if(file_exists($this->dataStr))
{echo "exist
";
copy($this->file_old,$this->file_new);
if(!$this->f_open=fopen($this->file_new,'w'))
{print "can't open file
";exit;}
if(!fwrite($this->file_new,"yaya"))
{print "can't write in this file
";exit;}
print "write sucess";
fclose(!$this->f_open);
}
else
{ mkdir($this->dataStr);}//创建目录
}
}
$newhtme=new FmsgToHtml();
?>
--------------
输出
------------
exist
can't write in this file
------------
请高手指点。
if(!$this->f_open=fopen($this->file_new,'w'))
{print "can't open file
";exit;}
if(!fwrite($this->file_new,"yaya"))
{print "can't write in this file
";exit;}
请注意,文件打开后的文件句柄是存放在 $this->f_open 属性的,所以写文件的时候,使用的句柄应该是 $this->f_open 而不是 $this->file_new