我在我的页面上收到警告
警告:fclose():提供的参数不是有效的流资源
使用以下代码
$fp = fopen('data.txt', 'w');
$write = '2';
fwrite($fp, $write);
fclose($fp);
更新代码
if(isset($_REQUEST['go1']))
{
$fp = fopen('data.txt', 'w');
$write = '1';
$fp1 = fopen('file.php', 'w');
$write1 = '<br><img src="/1/online.png" style="position:absolute; z-index:-2;" />';
}
if(isset($_REQUEST['go2']))
{
$fp = fopen('data.txt', 'w');
$write = '2';
$fp1 = fopen('file.php', 'w');
$write1 = '<br><img src="/1/offline.png" style="position:absolute; z-index:-2;" />';
}
fwrite($fp, $write);
fclose($fp);
fwrite($fp1, $write1);
fclose($fp1);
$fp = fopen('data.txt', 'r');
$contents = fread($fp, filesize('data.txt'));
fclose($fp);
if($contents == '1')
include('file.php');
else if($contents == '2')
include('file.php');
else
echo 'Something else...';
在第 27 行和第 29 行第 27 行得到错误
fclose($fp);
第 29 行
fclose($fp1);