不能让$ cnt ++工作 [英] Can't get $cnt++ to work

查看:158
本文介绍了不能让$ cnt ++工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个简单的点击计数器。如果我用#cnt = $ cnt + 1替换$ cnt ++;

,它就有效;

我不明白为什么这不起作用。任何想法?

if(file_exists(" counter.dat")){

$ f = fopen(" counter.dat"," r");

$ cnt = fread($ f,10);

// echo" \ n"," count 1 =",$ cnt," \ n" ;;

fclose($ f);

// $ cnt ++; DOESN''T WORK !!!

$ cnt = $ cnt + 1;

// echo" \ n"," count 2 =", $ cnt," \ n";

$ f = fopen(" counter.dat"," w");

fwrite($ f,$ cnt);

fclose($ f);

printf(\ n%d人们访问过此页面\ n,$ cnt);

}


谢谢,

Wilfred


I have a little simple hit counter. It works if I replace $cnt++;
with #cnt = $cnt + 1;
I can''t see why this doesn''t work. Any ideas?
if(file_exists("counter.dat")) {
$f = fopen("counter.dat", "r");
$cnt = fread($f, 10);
//echo "\n", "count 1 = ", $cnt, "\n";
fclose($f);
//$cnt++; DOESN''T WORK!!!
$cnt = $cnt + 1;
//echo "\n", "count 2 = ", $cnt, "\n";
$f = fopen("counter.dat", "w");
fwrite($f, $cnt);
fclose($f);
printf("\n%d people have visited this page\n", $cnt);
}

thanks,
Wilfred

推荐答案

cnt ++;

,#cnt =
cnt++;
with #cnt =


cnt + 1;

我不明白为什么这不是工作。任何想法?

if(file_exists(" counter.dat")){
cnt + 1;
I can''t see why this doesn''t work. Any ideas?
if(file_exists("counter.dat")) {


f = fopen(" counter.dat", r,;
f = fopen("counter.dat", "r");


这篇关于不能让$ cnt ++工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆