Question

In the past I have successfully setup phpmyadmin in Appfog. I added username and password credentials to phpmyadmin's Env Variables using the Appfog console. Phpmyadmin picks up those Env Variables and uses them to help the with the login process.

Now I want to put a SMTP password into an Env Variable and access it with a PHP library so that I don't have to store the SMTP password in a static PHP file on the server.

I added an Env Variable to the PHP instance that is hosting my SlimPHP installation on Appfog.

How do I extract that Env Variable from the PHP server correctly? I have echoed out a phpinfo() and can see the Env Variable in the output. I have used getinv, but I keep coming up with a 'index not found' error using the following code:

$p = getenv['PMA_SMTP_P'];

var_dump($_ENV) Result:

array(0) {}

phpinfo(INFO_ENVIRONMENT) Result:

PMA_SMTP_P variable is displayed with the correct value.

phpinfo(INFO_VARIABLES) Result:

PMA_SMTP_P variable not shown in the result
Was it helpful?

Solution

Read the manual: http://php.net/manual/en/reserved.variables.environment.php

But, the short answer, is you should be able to do:

$_ENV["PMA_SMTP_P"]

Or

getenv['PMA_SMTP_P'];

If neither is returned, we'll need more information, maybe some output from your phginfo

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top