How to understand this code
private static function parse_conf(&$setting_config){$nc_config = $GLOBALS['config'];if(is_array($nc_config['db']['slave']) && !empty($nc_config['db']['slave'])){$dbslave = $nc_config['db']['slave'];$sid = array_rand($dbslave);$nc_config['db']['slave'] = $dbslave[$sid];}else{$nc_config['db']['slave'] = $nc_config['db'][1];}$nc_config['db']['master'] = $nc_config['db'][1];$setting_config = $nc_config;$setting = ($setting = rkcache('setting')) ? $setting : rkcache('setting',true);$setting['shopnc_version'] = 'E-Mall';$setting_config = array_merge_recursive($setting,$nc_config);}
Reply to discussion (solution)
Parsing configuration ..
Parsing configuration ..
You do not need to know this. please take a moment.
Parsing configuration ..
You do not need to know this. please take a moment.
Well, let's analyze it.
$ Setting_config is a variable passed in by reference. according to the last sentence, we can see that this function is mainly used to generate the value of this variable.
The front-edge logic is also quite understandable, except that you do not know where to define a global variable $ config which defines the configuration information of the master-slave (master-slave) database in $ config, if multiple slave databases are configured, they are randomly used as the current Slave Database. if one database is configured, the master and slave databases are directed to this unique database.
I don't know what the rkcache function is for, so I will ignore it. I believe you can understand the following assignment statement.