PHP Class Variables Reassignment -


Is it possible to return the "blue" method to the following time?

  class test class {public $ var1 = "red"; Public function foo () // returns red (return $ this-> var1;} public function bar () // still returns red ($ this-> var1 = "blue"); return $ $ for this- > I know that class property can not be variable, additional results, etc. I read about overloading using __set and __get , Although it seems to be fully geared towards dynamic properties.   

As you describe it Your code word Works in the Structure from PHP Interactive Shell:

  php> $ T = New Test Class (); Php> Echo $ t-> foo (); Red Php & gt; ; Echo $ t-> Bar (); Blue Php> Echo $ t-> foo (); blue   

Perhaps you have your problem in a different way Can you explain?

Comments