我正在嘗試爲朋友構建一個小框架,每次按下某個按鈕時都會播放某個動畫。他想要一種方法來統計點擊按鈕的次數,但我似乎無法得到該部分的工作。我究竟做錯了什麼?所有的Button在PHP中單擊計數器
<?php
if(isset($_POST['mushu']))
{
echo "Working.";
playAnimation();
clickInc();
}
function playAnimation()
{
/* ... */;
}
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 $clicks[0];
}
?>
<html>
<head>
<title>Adobe Kitten</title>
</head>
<body>
<form action="<?php $_SERVER['PHP_SELF']; ?>">
<input type="button"
value="Let's see what Mushu is up to."
name="mushu">
</form>
</body>
</html>
什麼不起作用?任何錯誤給出?或者它只是不增加你存儲的數量? – 2010-08-04 21:20:56
目前,該文件未打開。之前,問題是按鈕單擊時根本沒有發生任何事情。 – Andy 2010-08-04 21:54:07