So I created a test app using Application Manager. Inside of my application path how would I call my pre set variables using PHP.
Also I would like to note I am using linux godaddy shared hosting.additional info:
I am just trying to have somewhat "secure" environment variables and am not familiar with what the "best practice" is. In a local environment if I was using nodejs I understand how to use dotenv.
Also,
I was reading this cpanel documentation but I cant find how I call the vairables using php from my Application path.
https://docs.cpanel.net/cpanel/software/application-manager/82/
Application Name:
test_app
Deployment Domain:
mytestsite.com
Base Application URL:
mytestsite.com/
Application Path:
home/mytest-folder
Environment Variables:
test_var = test
Using PHP inside of home/mytest-folder how would I call or be able to get the value of my variable test_var.
CodePudding user response:
You should be able to get the environment variable using any of the following:
// this should work if `variables_order` includes the 'E' option
$variable = $_ENV['test_var'] ?? null;
// if not `variables_order` includes the 'E' option
// then this should work and it will also populate the '$_ENV' array with the requested variable
$variable = getenv('test_var');
// could be used as a fallback
$variable = $_SERVER['test_var'] ?? null;
Reference: