I have a different config files for a script that runs both on a dev and production server. The question is, can I detect somehow which is which ?
To Check if an Environment Variable ExistsSelect Start > All Programs > Accessories > Command Prompt. In the command window that opens, enter echo %VARIABLE%. Replace VARIABLE with the name of the environment variable.
To display the values of environment variables, use the printenv command. If you specify the Name parameter, the system only prints the value associated with the variable you requested.
A command-line interface (CLI) is a text-based user interface (UI) used to run programs, manage computer files and interact with the computer. Command-line interfaces are also called command-line user interfaces, console user interfaces and character user interfaces.
The most used command to displays the environment variables is printenv . If the name of the variable is passed as an argument to the command, only the value of that variable is displayed. If no argument is specified, printenv prints a list of all environment variables, one variable per line.
Have a different bootstrap file to include depending on the server you're on. So
include "bootstrap.php";
// your script etc..
On the production box, bootstrap.php will have a constant IS_DEV = FALSE
On the development box, bootstrap.php will have the same constant IS_DEV = TRUE
So the same script will include the same file name, bootstrap.php, but the contents of bootstrap will have different values for the IS_DEV
constant variable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With