Home  >  Article  >  Backend Development  >  这段代码如何理解

这段代码如何理解

WBOY
WBOYOriginal
2016-06-20 12:55:57923browse

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'] = '<span class="vol"><font class="b">E-</font><font class="o">Mall</font></span>';		$setting_config = array_merge_recursive($setting,$nc_config);	}


回复讨论(解决方案)

解析配置..

解析配置..


这不用你说都知道,请稍息


解析配置..


这不用你说都知道,请稍息

好吧 那就分析分析

 $setting_config 是引用传递进来的一个变量,根据最后一句应该能看出来这个函数主要就是用来生成这个变量的值的。

前边逻辑也蛮好理解,无非是你不知道在哪里定义了一个全局变量$config 这个$config里面定义了主从(master-slave)数据库的配置信息,如果配置了多个从数据库就随机一个用来作为当前的从数据库,如果就配置了一个数据库,那就主从的数据库都是指向这个唯一的数据库。

因为不知道rkcache这个你自定义的函数是用来干嘛的 所以就忽略了,下面那句赋值语句 我相信你是看得懂的。
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn