Environment variables are variables that can be set differently in different environments.
A variable is a container that you can put some data in. An environment is a word that’s a bit hard to define, but it basically means a system or a set of systems that is used for a specific purpose.
To explain this with examples might be easier.
At work we do software development. The developers use the development environment. This is a collection of servers that we have dedicated for developers to use for development. Once the developers have developed their code they will copy it to the test environment, which is a collection of servers that is set up for testers to use. Once it passes testing we move it to the Production environment and the code is live.
Now imagine that this code needs to open a file. We have three copies of this file. One in the development environment, one in the test environment, and one in production. The files are all in different locations, so in each environment we store the location of the file for that environment in an environment variable. Then when the code needs the file it can get the correct file path from the environment variable, which is called like “file name” in all environments, so the code only needs to know the name of the environment variable to get the correct file path for the environment that it’s running in.
Latest Answers