In php, I have 2 command like that (my wesite run on ubuntu os): cmd1:
exec("tmp=123");
cmd2:
$test = exec('echo $tmp');
Why cmd2 don't know: $tmp. How can I catch $tmp in cmd 1, thanks a lot
In php, I have 2 command like that (my wesite run on ubuntu os): cmd1:
exec("tmp=123");
cmd2:
$test = exec('echo $tmp');
Why cmd2 don't know: $tmp. How can I catch $tmp in cmd 1, thanks a lot
exec
executes an external program in it's own environment which ceases to exist after the process finishes, if you wish to pass an environment variable to a external program you need to set it using putenv
, for example:
putenv('tmp=123');
$test = exec('echo $tmp');
This usage is rather strange though, you may want to re-think your design.