How to understand this code-php Tutorial

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.