See this headline, there are two questions, is to set the system environment variable to the Php.exe, or to set the programming language to directly invoke the environment variable, say here some people may faint, because we often see is the first, is equivalent to a command to set shortcuts, do not go into the installation of the application directory and then hit the command. For example: 1, did not add php.exe Global environment variables, we run PHP needs in the following directory can be:
D:\phpStudy\php\php-5.6.27-nts\
Note: This is my Php.exe installed directory, you may not be the same as mine, it is not important.
For example, to view the PHP version information:
Php-v
To View the PHP expansion module:
Php-m
This is a very troublesome thing and I want to use PHP commands anywhere, so you should add php.exe to the Global environment variable.
This is very simple, most of the program is the same set global variables, find the computer, point right button, open the control system panel system, the left side of the advanced system settings, point to see the. Picture steps as follows: first step:
Step Two:
Step Three:
Fourth Step:
Fill in the installation path of your software, you will be able to automatically identify your face executable file,. exe,. Bat,.phar, etc. executable files, and then you can directly use the PHP command anywhere. Isn't it cool? 2. Set the environment variable for PHP getenv () and $_env () functions:
It's not over yet, I need to set the environment variable for PHP, which is the kind of environment variable that can be obtained directly with getenv () and $_env (). Then you need to see here, the online tutorial has not yet, I also grope out.
In three steps: The first step: Modify the php.ini file, the following code:
Variables_order = "Egpcs"
The default value is ' GPCs ', which means: Get, POST, COOKIE, ENV and server,e represent environment, meaning environment variables. Step Two:
Follow the previous steps to open the Environment variable Settings window:
Set up the environment variables you need here, such as the database account password, and so on. I played mosaic here, is necessary. Step Three: Restart the computer, and then it will take effect. Setting a global variable for Php.exe does not require you to restart your computer.
After the reboot, you can use it directly in the program. For example, in my PHP program. You can directly:
echo getenv (' Db_host_name)
//or Echo $_env (' Db_host_name ')
Is it OK. Try it quickly.
Reference Link: http://blog.csdn.net/zhezhebie/article/details/72734590