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.