Setting PHP enviromental variable while running command line script

后端 未结 7 1409
情书的邮戳
情书的邮戳 2020-12-08 20:48

I need to run a PHP script from command line and I need to set some environmental variables. Unfortunately, following does not work:

php -dAPPLICATION_ENV=st         


        
7条回答
  •  半阙折子戏
    2020-12-08 21:20

    When you execute a PHP script from the command line, it inherits the environment variables defined in your shell. That means you can set an environment variable using the export command like so:

    export APPLICATION_ENV='staging'
    

提交回复
热议问题