I am storing multiple objects into a config array.
for example like this
class Test
{
private $config = array();
public function __construct()
{
$this->abc();
$this->def();
}
public function abc()
{
$this->config['abc'] = new someClass('abc');
}
public function def()
{
$this->config['def'] = new someClass('def');
}
public function printTest()
{
return $this->config;
}
}
class someClass
{
public function __construct($value)
{
echo $value;
}
}
my problem that i do see the object data when I print_r the config variable. What I cannot understand is why I cannot echo out the value of the first object abc after i try storing the second object def into the config array.
When you want to print config[‘def’] you need to express that that is the data you want. Now that
is
you just say
Personally, I feel like a function named printSomething() should print the data to the screen (or atleast return a string, so I’d say