Simple question, is it possible to access a static variable from a $this-> call?
class testA { public static $var1 = "random string"; // current solution public function getVar() { return self::$var1; } } class testB { private $myObject; public function __construct() { $this->myObject = new testA(); // This line is the question echo $this->myObject::var1; // current solution echo $this->myObject->getVar(); } } I'm afraid I've answered my own question. But having a few static variables I didn't want to have a function for each variable, Or even a single getVar($staticVar) when I could access it directly.
If this is the only solution. Any recommendations on a better way to implement this.
If I'm going to require a function call for each, I might as well get rid of the static variables altogether.
//method public function staticVar1() { return (string) 'random string'; }