CodeIgniter configuration-config. php Usage example analysis, codeigniterconfig_PHP tutorial

Source: Internet
Author: User
CodeIgniter config. php Usage instance analysis, codeigniterconfig. CodeIgniter configuration-example analysis of config. php Usage. codeigniterconfig This article analyzes the usage of config. php in CodeIgniter configuration. For your reference, we will share the following details: configure the config. php Usage instance for CodeIgniter configuration, codeigniterconfig

This article analyzes the usage of config. php in CodeIgniter configuration. We will share this with you for your reference. The details are as follows:

Configuration instructions

$ Config ['language']: specifies the Project language pack. Note that the class library that comes with Codeigniter prompts that the language pack is in the/system/language/english/Directory. if you want to use these class libraries when configuring non-english, copy the language pack to the specified directory. Otherwise, a load error occurs.

$ Config ['charset']: sets the encoding used by the system. it is used in some functions that require encoding. the system and database are encoded in a unified manner.

$ Config ['enable _ Hooks']: Hook Switch Control. if it is set to true, hooks are allowed. otherwise, hooks are not allowed.

$ Config ['subclass _ prefix']: Set the prefix of the custom class library and function. the default value is MY _. for example, when you need to override the lang method in language helper, you only need to create my_javasage_herper.php in the helper directory and implement the lang function to implement "overload ". Here, MY _ is the value defined in subclass_prefix.

$ Config ['permitted _ uri_chars']: sets the characters allowed in the URL.

$ Config ['log _ threshold ']: Set the log record level. if it is 0, the log record is disabled. if it is 4, all information is recorded. generally, set it to 1. After setting, check whether the logs Directory has the write permission.

$ Config ['proxy _ IP']: when the server uses a proxy, REMOTER_ADDR obtains the IP address of the proxy server, it must be obtained from HTTP_X_FORWARDED_FOR, HTTP_CLIENT_IP, HTTP_X_CLIENT_IP, HTTP_X_CLUSTER_CLIENT_IP, or other preset values. The IP addresses of proxy servers are set here, which are separated by commas.

$ Config ['encryption _ key']: the encryption value. if you want to use the SESION that comes with CI, you must set this value. In CI's built-in SESSION storage and Cookie, encryption is performed for security reasons.

Read configuration

The config. php file is loaded through the get_config function during CI initialization, and config_item is also provided to obtain the config value, for example:
The code is as follows: echo config_item ('charset ');
CI also provides a configuration class to maintain the configuration file. You can also use the following method to obtain and set the config value. after the setting, the result of calling get_config will also change, so you can modify the config value before some logic.

// Obtain the charset value configured in config echo $ this-> config-> item ('charset '); // reset the charset value in config $ this-> config-> set_item ('charset', 'gbk ')

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.