在PHP脚本中访问Apache环境(CLI)

I currently have a script which will run via the browser and separately via the "php" command line tool.

Now the problem is, I am able to access the Apache Environment variables while script being called from the browser, but unable to access it while the script is called via command line.

How can I get the Apache environment available to the command line script as well ?

First, you must declare your environment variable using this command:

export APPLICATION_ENV=development

Then you can get it in your application cli with the function getenv('APPLICATION_ENV');.