Variables $ _ SERVER, $ _ ENV, and define are confused about defining system parameters.

Source: Internet
Author: User
After reading some frameworks, many of them use define to define many system parameters at the system core entrance. However, we recently see that some of them are defined in $ _ SERVER and even $ _ ENV. Although all functions can be implemented, I have been confused. What are the advantages of this definition? Or... after reading some frameworks, many of them use define to define many system parameters at the system core entrance. However, we recently see that some of them are defined in $ _ SERVER and even $ _ ENV.

Although all functions can be implemented, I have been confused. What are the advantages of this definition? Or can it slightly improve performance? Answers ~

Reply content:

After reading some frameworks, many of them use define to define many system parameters at the system core entrance. However, we recently see that some of them are defined in $ _ SERVER and even $ _ ENV.

Although all functions can be implemented, I have been confused. What are the advantages of this definition? Or can it slightly improve performance? Answers ~

Add the following code to. htaccess:

SetEnv database_name your_databaseSetEnv mysql_user your_usernameSetEnv mysql_password your_password

In this case, you can use$ _ SERVER ['database _ name'],$ _ SERVER ['mysql _ user'],$ _ SERVER ['mysql _ password']To access these values.

To put it bluntly, the Global Array $ _ SERVER can use apache to add some key values, while constants cannot. They can only be defined using define in the PHP file.

It is seldom seen that variables are directly put in $ _ SERVER, $ _ ENV, because both variables are semantic variables.
In addition, constants themselves have high performance, so here should not be based on performance considerations, maybe just a bad personal hobby.

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.