Example:
class LOL{ const FOO = 1; } $x = new LOL; $arr = array('x' => $x); echo $x::FOO;
But if I make my class instance a property, I can no longer access the constant:
class WWW{ protected $lol; public function __construct($lol){ $this->lol= $lol; } public function doSMth(){ echo $this->lol::FOO;
: (
I know that I can just do echo LOL::FOO
, but what if the class name is unknown? From this perspective, I only have access to this object / property, and I really do not want this WWW class to be βawareβ of other classes and their names. It should just work with this object.
source share