php fclose()函数 语法

作用:关闭一个打开文件

语法:

fclose(file)

参数:

file 必需。规定要关闭的文件。

说明:如果成功则返回 true,否则返回 false。文件指针必须有效,并且是通过 fopen() 或 fsockopen() 成功打开的。

php fclose()函数 示例

<?php
$file = fopen("./test.txt","r");
echo fclose($file);
?>

PHP Warning: fclose(): 怎么解决

我把r换成了r+,把w换成w+.
$file_name = ‘./inc/const.php’; //要替换操作的文件
@$fp = fopen($file_name,’r+’); //打开要替换的文件
@$conf_file = fread($fp,filesize($file_name));
$conf_file = preg_replace(“/httpurl\s*\=\s(\’|”)(.*?)(“|’)/”,”httpurl = “” . $httpurl. “””,$conf_file);
$conf_file = preg_replace(“/databasePrefixs*=s(‘|\”)(.*?)(\”|’)/”,”databasePrefix = \”” . $databasePrefix. “\””,$conf_file);
fclose(@$fp);
@$fp = fopen($file_name,’w+’);
$fw = fwrite($fp, trim($conf_file));
fclose($fp);
这样应该可以,否则把@去掉.

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。