class A extends CModel {
public $var1;
public $dynamic; //Declare dynamic as a class variable
public function __construct()
{
$this->dynamic= 'test';
}
}
The answer to your question can be found in the __set() magic method that is part of CComponent, which means all component subclasses are subject to this method of setting. The code does not allow for dynamic variables; as you can see, it throws an exception. For more information about the reasoning behind the method, read the CComponent documentation.
Thanks Jaymard. I just realized that I provided a bad example. But thanks to "Yoda Pop" and Calvaria in the other thread that you replied, I learned that I need to use magic functions (__set() & __get) to accomplish what I needed.
Thanks Master Yoda Pop
I definitely will go over the CComponent documentation. I have so many questions …, but I’m moving on with my project.