Prueba lo siguiente
Código PHP:
<?php
class Contador{
var $cont;
var $temp;
function Contador(){
$this->cont =0;
$this->temp= 0;
}
function incrementar(){
$this->cont= $this->cont +1+$this->temp;
$temp = $this->cont;
echo "aqui". $this->cont;
}
function getContador(){
return $this->cont;
}
}
?>
<?php
$c=new Contador();
$c->incrementar();
//echo $c->getContador();
$c->incrementar();
//echo $c->getContador();
?>