property not updating in object when page is posted

Posted by Jared on Stack Overflow See other posts from Stack Overflow or by Jared
Published on 2010-06-16T01:32:13Z Indexed on 2010/06/16 1:42 UTC
Read the original article Hit count: 328

Filed under:
|

Hi I have set a property in a constructor like so

function __construct()
{

$this->count = count(@$_SESSION['filearray']); //count how many files in array
}

and using it in condition statements if($this->count > 10) //then do something

but it appears the count isn't being updated when I use another method of injecting values into this 'filearray' until I refresh the page.

am I doing something wrong? I thought that my constructor would detect a change had been made in the session and whenever I call $this->count I would get the current count value but it seems to be 1 step behind until I refresh the page.

If this is all vague I can include my form page that has all the method calls, but this is the jist of my question, why is my property not updating and how do I fix it :)

TIA

© Stack Overflow or respective owner

Related posts about php

Related posts about object-oriented