PHP读写文件的错误!
temp.html和写文件的这个程序是在一个根目录下的,我运行下面的写文件操作程序,却提示出错!
Warning: fopen(temp.html) [function.fopen]: failed to open stream: No such file or directory in F:\test\8.php on line 5
Warning: filesize() [function.filesize]: stat failed for temp.html in F:\test\8.php on line 6
Warning: fread(): supplied argument is not a valid stream resource in F:\test\8.php on line 6
Warning: fopen(test/test.html) [function.fopen]: failed to open stream: No such file or directory in F:\test\8.php on line 13
文件:test/test.html不可写,请检查其属性后重试!
这个是怎么回事情?明显的一个读失败,一个写失败!
请各位高手帮忙
下面是写文件操作的代码!
<?
$title = "拓迈国际测试模板";
$file = "TwoMax Inter test templet,author:_Max>Matrix@Two_Max";
$fp=fopen("temp.html","r");
$content = fread($fp,filesize ("temp.html"));
$content = str_replace ("{file}",$file,$content);
$content = str_replace ("{title}",$title,$content);
$filename = "test/test.html";
$handle = fopen ($filename,"w"); //打开文件指针,创建文件
/*
检查文件是否被创建且可写
*/
if (!is_writable ($filename)){
die ("文件:".$filename."不可写,请检查其属性后重试!");
}
if (!fwrite ($handle,$content)){ //将信息写入文件
die ("生成文件".$filename."失败!");
}
fclose ($handle); //关闭指针
die ("创建文件".$filename."成功!");
?>
Warning: fopen(temp.html) [function.fopen]: failed to open stream: No such file or directory in F:\test\8.php on line 5
Warning: filesize() [function.filesize]: stat failed for temp.html in F:\test\8.php on line 6
Warning: fread(): supplied argument is not a valid stream resource in F:\test\8.php on line 6
Warning: fopen(test/test.html) [function.fopen]: failed to open stream: No such file or directory in F:\test\8.php on line 13
文件:test/test.html不可写,请检查其属性后重试!
这个是怎么回事情?明显的一个读失败,一个写失败!
请各位高手帮忙
下面是写文件操作的代码!
<?
$title = "拓迈国际测试模板";
$file = "TwoMax Inter test templet,author:_Max>Matrix@Two_Max";
$fp=fopen("temp.html","r");
$content = fread($fp,filesize ("temp.html"));
$content = str_replace ("{file}",$file,$content);
$content = str_replace ("{title}",$title,$content);
$filename = "test/test.html";
$handle = fopen ($filename,"w"); //打开文件指针,创建文件
/*
检查文件是否被创建且可写
*/
if (!is_writable ($filename)){
die ("文件:".$filename."不可写,请检查其属性后重试!");
}
if (!fwrite ($handle,$content)){ //将信息写入文件
die ("生成文件".$filename."失败!");
}
fclose ($handle); //关闭指针
die ("创建文件".$filename."成功!");
?>
...全文
西门子触摸屏教程wincc flexible2008 sp5 Smart V3 V4中文版软件 西门子触摸屏教程wincc flexible2008 sp5 Smart V3 V4中文版软件 阅读详情
相关推荐
PHP 读写文件操作实例
NULL 博文链接:https://sifutian.iteye.com/blog/554011
php-excel 读写
php-excel 读写,写成excel类,带例子
php文件读写与上传下载
php语言如何打开文件读写操作文件,以及php对文件的上传与下载,包括php配置文件关于上传文件大小的配置
PHP使用feof()函数读文件的方法
主要介绍了PHP使用feof()函数读文件的方法,以实例形式对比了正确与错误的用法,阐明了feof()函数的使用技巧,需要的朋友可以参考下
读写文件的源代码资源
读写文件 读写文件 读写文件 读写文件 读写文件 读写文件 读写文件 读写文件


基础编程
