Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] Creating libraries - can PHP 4 class properties retain their value between function calls?
#1

[eluser]MMacdonald[/eluser]
I'm creating my own library. Even though I run PHP 5, I'm coding to PHP 4 to keep it reusable. The gist of my problem is shown in the following pseudo-code - specifically, how do I get PHP 4 to make $property retain its value between function calls?

Code:
class library_example {

var $property="";

function write($value)
  {
   $this->property=$value;
  }

function read()
  {  
   return $this->property;
  }

}
#2

[eluser]MMacdonald[/eluser]
I've solved this myself - the code does behave exactly as expected - I'd forgotten that I next time the page loads, it's a new instance of the class.
#3

[eluser]Colin Williams[/eluser]
Yerp.. Stateless is the way to think




Theme © iAndrew 2016 - Forum software by © MyBB