如何做一个PHP计数器? [英] How can I make a PHP counter?
本文介绍了如何做一个PHP计数器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道我在Javascript中做过一次,但是如何在PHP中做呢?
基本上我想这样做:
I know I have done this in Javascript once, but how can I make it in PHP? Basically I want to do this:
if (empty($counter)){
$counter = 1;
}else{
"plus one to $counter" ($counter++?)
}
但是它没有工作,当我试着。我怎么会这样做?
But it didn't work when I tried. How would I go about doing this?
谢谢:)
编辑:这是我可以做的:
This is so I can do:
if ($counter == 10){
echo("Counter is 10!");
}
编辑:
这是所有在一个while(),所以我可以计算它进行了多少次,因为LIMIT将不工作,我正在做的查询。
This is all in a "while()" so that I can count how many times it goes on, because LIMIT will not work for the query I'm currently doing.
推荐答案
为什么会有额外的if?
我将这样做:
why the extra if into the while? i would do this:
$counter = 0;
while(...)
{
(...)
$counter++;
}
echo $counter;
这篇关于如何做一个PHP计数器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文