I have create the following class :
Main class file
class NativeTabs
{
private $tabs = array();
public function __construct()
{
require_once('/options_elements.php');
}
public function add_tab($key = '', $name = '')
{
// ...
$this->tabs[$key] = $name;
$this->tabs[$key][] = new OptionsElements();
// ...
}
}
$nt = new NativeTabs();
$nt->add_tab('tabname', "Tab Name");
options_elements.php File
class OptionsElements
{
public function __construct()
{
}
}
And when I execute that code I get the following error :
Fatal error: [] operator not supported for strings in PATH/TO/MY/FILEnative_tabs.php on line THE_LINE_THAT_CONTAIN_THE_CODE($this->tabs[$key][] = new OptionsElements();)
Why I can't assing the object in $this->tabs[$key][]
?
Any idea please ?