Sample code of thinkPHP5.0 framework environment variable configuration

Source: Internet
Author: User
This article mainly introduces the environment variable configuration method of thinkPHP5.0 framework, and analyzes the functions, definitions, configurations, and precautions of the environment variables in thinkPHP5.0 in the form of instances, for more information about how to configure environment variables in thinkPHP5.0, see the next article. This article analyzes the functions, definitions, configurations, and precautions of environment variables in thinkPHP5.0 using examples, for more information, see

This document describes how to configure environment variables of the thinkPHP5.0 framework. We will share this with you for your reference. The details are as follows:

Environment variable configuration is allowed, and the priority level is higher than that in the configuration file, because when reading configuration parameters, the system first checks whether the configuration exists in the environment variable.

During development, you can simulate environment variable configuration under the application root directory. the configuration parameter definition format in the. env file adopts the ini method, for example:

app_debug = trueapp_trace = true

If the environment variables are configured separately in your deployment environment, delete the. env configuration file to avoid conflicts.

Parameters configured for environment variables are converted to uppercase values. values of null, no, and false are equivalent to "", and values of yes and true are equivalent to "1 ".

The default environment variable prefix of ThinkPHP5.0 is PHP _. you can also reset it by changing the ENV_PREFIX constant.

Note:Environment variables do not support array parameters. if you need to use array parameters, you can use underscores to separate and define the configuration parameter names:

database_username = rootdatabase_password = 123456

Or use

[database]username = rootpassword = 123456

You can use the following two methods:

Config: get ('database. username'); Config: get ('database. password '); // You can also get Config: get ('database _ username'); Config: get ('database _ password') in the following way ');

The above is a detailed description of the sample code of thinkPHP5.0 framework environment variable configuration. For more information, see other related articles in the first PHP community!

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.