4

我在PHP中尝试了以下

    $AWS_environment_variables = array(
        "AWS_PATH"              => NULL,
        "AWS_AUTO_SCALING_HOME" => NULL,
        "AWS_IAM_HOME"          => NULL,
        "AWS_ELB_HOME"          => NULL,
        "HOSTNAME"              => NULL,
        "EC2_AMITOOL_HOME"      => NULL,
    );

    foreach($AWS_environment_variables as $key_name => &$value){
        $value = getenv($key_name);
    }

    echo "<pre>"; 
    print_r($AWS_environment_variables); 
    echo "</pre>";

在 ec2 中运行时,我得到以下信息。所有 AWS 特定的东西都是空的

Array
(
    [AWS_PATH] => 
    [AWS_AUTO_SCALING_HOME] => 
    [AWS_IAM_HOME] => 
    [AWS_ELB_HOME] => 
    [HOSTNAME] => 
    [EC2_AMITOOL_HOME] => 
)

标签#HowDoIDoIt?

4

1 回答 1

2

尝试这个

print_r($_ENV);
print_r($_SERVER);
print_r($GLOBALS);
phpinfo();

你应该在那里找到变量(参考 - https://forums.aws.amazon.com/message.jspa?messageID=447927

于 2013-07-09T16:19:01.857 回答