比如
class test
{
    function test()
    {
        //这里要判断上次的$time记录是多少.如果重复就要原有基础上+1,如果不重复就重新取值
        if($time == time())
        {
            $time++;
        }else{
            $time = time();
        }
    }
}$test = new test();
echo $test->test();
echo $test->test();

解决方案 »

  1.   

    这类设计的....这需要写成个类吗?如果非要的话你可以加一个
    protected $time;
    来存储嘛,然后判断传递进来的值是否一样再进行操作.
      

  2.   

    那就将就的理解一下吧
    class test
    {
        protected $time;    public function changeTime($value)
        {
            if ($this->time !== $value) {
                $this->time = $value;
            } else {
                $this->time++;
            }
        }    public function showTime(){
            return $this->time;
        }
    }$mytest=new test();
    $mytest->changeTime(1);
    $mytest->changeTime(1);
    echo $mytest->showTime();