Example analysis of config.php usages of codeigniter configuration _php Example

Source: Internet
Author: User
Tags pack codeigniter

The config.php usage of codeigniter configuration is analyzed in this paper. Share to everyone for your reference, specific as follows:

Configuration Instructions

$config [' Language ']: Specifies the project language pack. When you need to be aware of the CodeIgniter class library error prompt language pack is located in the/system/language/english/directory, when you configure non-Chinese, if you need to use these class libraries, you need to copy the language pack into the specified directory, Otherwise, there will be a load error.

$config [' CharSet ']: Set the system to use the encoding, in some need to specify the encoding function will be used, the system, the database unified coding can be.

$config [' Enable_hooks ']: Hook switch control, set to True to allow the use of hooks, otherwise not allowed.

$config [' Subclass_prefix ']: Sets the custom class library, the function prefix, defaults to my_, such as when you need to rewrite the Lang method in the language helper, just create the My_ in the helper directory language_herper.php, and implement the Lang function to implement "overload." Here My_ is the value defined in Subclass_prefix.

$config [' Permitted_uri_chars ']: Sets the allowed characters in the URL.

$config [' Log_threshold ']: Set the logging level, 0 to turn off logging, and 4 to record all information, typically set to 1. After setting, you need to confirm that the logs directory has write permissions.

$config [' proxy_ips ']: When the server uses the agent, remoter_addr to get the IP of the proxy server, the need from Http_x_forwarded_for, HTTP_CLIENT_IP, Http_x_client_ip, HTTP_X_CLUSTER_CLIENT_IP, or other set of values. Set here is the proxy server IP, comma-delimited.

$config [' Encryption_key ']: Encrypt the value, and you must set it if you want to use the sesion from the CI band. The self-contained session of CI is stored in the cookie and is encrypted for security purposes.

Configure read

CI initialization begins by loading the config.php file with the Get_config function, as well as providing config_item to obtain the value of config, such as:

Copy Code code as follows:
echo Config_item (' CharSet ');

CI also provides a configuration class for maintaining configuration files. You can also get and set the value of config in the following way, and the result of calling Get_config after the setting changes, so you can modify the config value before some logic.

Gets the charset value configured in config
echo $this->config->item (' CharSet ');
Reset the value of the CharSet in config
$this->config->set_item (' CharSet ', ' GBK ')

More about the CodeIgniter framework interested readers can view the site topic: "CodeIgniter Introductory Course"

I hope this article will help you with the PHP program design based on CodeIgniter framework.

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.