当对象名称(类别)直接放置时,它返回正确的值,如:
原文链接:https://www.f2er.com/php/133820.html$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; }