当直接输入对象名称(类别),它会返回正确的值。例如:
但是,当把对象名称存储在名为 $dataname 的变量中时,它会返回空白,例如:
$primary = $this->dbmapper->category['primary'] ; // ( Correct Output )
但是,当把对象名称存储在名为 $dataname 的变量中时,它会返回空白,例如:
$dataname = 'category';
$primary = $this->dbmapper->$dataname['primary'] ; ( Blank Output )
我的构造函数变量是:
$this->dbmapper = $this->mapper();
我的功能是:
function mapper($module='')
{
$mapper = array();
$mapper['category']['table'] = 'allcategory';
$mapper['category']['primary'] = 'categoryID';
$mapper['page']['table'] = 'allpages';
$mapper['page']['primary'] = 'pageID';
return (object) $mapper;
}