Export a variable from PHP to shell

后端 未结 2 716
野趣味
野趣味 2021-01-13 08:10

I\'m trying to set a variable that should be accessible from outside PHP. Ideally this should be a local variable, but environment variables are also welcome.

First,

2条回答
  •  清歌不尽
    2021-01-13 08:37

    Environment variables that are exported are only available in child processes.

    So you'll be able to set an environment variable and then spawn a child process. The environment variable will be visible in that child process. However setting it in php and then launching a successive process (echo, in your example above) won't work.

    If you set the variable and then spawn/exec a new process, it should be visible in that new process.

提交回复
热议问题