POST TIME:2020-04-04 21:38
DedeCMS數據庫的信息是寫在data/common.inc.php,而系統連接數據庫時使用的有一個函數是:
functionInit($pconnect=FALSE){
$this->linkID=0;
$this->dbHost=$GLOBALS['cfg_dbhost'];//$GLOBALS在哪把信息放入$GLOBALS的?
$this->dbUser=$GLOBALS['cfg_dbuser'];
$this->dbPwd=$GLOBALS['cfg_dbpwd'];
$this->dbName=$GLOBALS['cfg_dbname'];
$this->dbPrefix=$GLOBALS['cfg_dbprefix'];
$this->result["me"]=0;
$this->Open($pconnect);}
它是在哪把信息放入$GLOBALS中的?
回復:
$GLOBALS是全局變量數組
凡是在函數和類以外定義的變量都在其中出現
比如$GLOBALS['cfg_dbhost']就在common.inc.php中有$cfg_dbhost='~dbhost~';
當加載common.inc.php后就有$GLOBALS['cfg_dbhost']