php 计数器,警告:fopen(clickcount.txt):无法打开流
php counter, Warning: fopen(clickcount.txt): failed to open stream
我从http://www.whosebug.com/questions/3409885/button-click-counter-in-php复制了一个代码,它计算了我点击提交的次数。但每点击 20/40 次就会出现此错误:警告:fopen(clickcount.txt):无法打开流:第 17 行 C:\Users\nieke\Dropbox\wamp\wamp64\www\periode2\niek\spel2\klikspel.php 中的参数无效。
这是代码:
<!DOCTYPE html>
<html>
<head>
<title>Klik</title>
<link rel="stylesheet" type="text/css" href="klikspelstyle.css">
</head>
<body>
<?php
function clickInc()
{
$count = ("clickcount.txt");
$clicks = file($count);
$clicks[0]++;
$fp = fopen($count, "w") or die("Can't open file");
fputs($fp, "$clicks[0]");
fclose($fp);
echo "<h3>aantal munten = $clicks[0]</h3>";
}
?>
<div id="header">
<center>
<?php
if(isset($_POST['knop'])){
clickInc();
}
?>
</center>
</div>
<div id="kliknop">
<center>
<form action="" method="POST" name="knop">
<input type="submit" name="knop" value="werken">
</form>
</center>
</div>
<?php
?>
</body>
</html>
尽量不要使用 Dropbox 目录。问题可能是 Dropbox 同步。
我从http://www.whosebug.com/questions/3409885/button-click-counter-in-php复制了一个代码,它计算了我点击提交的次数。但每点击 20/40 次就会出现此错误:警告:fopen(clickcount.txt):无法打开流:第 17 行 C:\Users\nieke\Dropbox\wamp\wamp64\www\periode2\niek\spel2\klikspel.php 中的参数无效。 这是代码:
<!DOCTYPE html>
<html>
<head>
<title>Klik</title>
<link rel="stylesheet" type="text/css" href="klikspelstyle.css">
</head>
<body>
<?php
function clickInc()
{
$count = ("clickcount.txt");
$clicks = file($count);
$clicks[0]++;
$fp = fopen($count, "w") or die("Can't open file");
fputs($fp, "$clicks[0]");
fclose($fp);
echo "<h3>aantal munten = $clicks[0]</h3>";
}
?>
<div id="header">
<center>
<?php
if(isset($_POST['knop'])){
clickInc();
}
?>
</center>
</div>
<div id="kliknop">
<center>
<form action="" method="POST" name="knop">
<input type="submit" name="knop" value="werken">
</form>
</center>
</div>
<?php
?>
</body>
</html>
尽量不要使用 Dropbox 目录。问题可能是 Dropbox 同步。