Setting PHP enviromental variable while running command line script

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

    Try using putenv and pass the variables through parameters

    php script.php APPLICATION_ENV=staging
    

    And in the script.php code:

    for($i=1;$i

提交回复
热议问题