PHP fclose函数用法总结
phpfclose()函数语法
作用:关闭一个打开文件
语法:
fclose(file)
参数:
file必需。规定要关闭的文件。
说明:如果成功则返回true,否则返回false。文件指针必须有效,并且是通过fopen()或fsockopen()成功打开的。
phpfclose()函数示例
PHPWarning: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("/databasePrefix\s*\=\s(\'|\")(.*?)(\"|')/","databasePrefix=\"".$databasePrefix."\"",$conf_file);
fclose(@$fp);
@$fp=fopen($file_name,'w+');
$fw=fwrite($fp,trim($conf_file));
fclose($fp);
这样应该可以,否则把@去掉.
热门推荐
1 训练狗狗搜寻
2 如何训练狗狗装死
3 狗狗训练书
6 怎么训练狗狗拜年
8 狗狗训练游戏
10 狗狗嗅觉训练
11 怎么训练狗狗在笼子里不叫
12 怎么训练狗狗站立走路
13 怎么训练狗狗在马桶上
14 狗狗尿尿怎么训练
15 训练狗狗用品
16 泰迪狗狗的训练方法大小便
17 训练狗狗可以打吗
18 王曼丽的狗狗训练