Setting PHP enviromental variable while running command line script

后端 未结 7 1397
情书的邮戳
情书的邮戳 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:39

    You can set a variable in /etc/environment like FOO="bar" which is then accessible with getenv() in both CLI and web requests. You may need to relog for this change to take effect.

提交回复
热议问题