如何在PHP中设置$ PATH? [英] How to set $PATH in PHP?
问题描述
./ bin
,这样当我使用 exec()
和类似的函数,它只会搜索该目录中的二进制文件(除非我明确地另有说明)。 我已经尝试过 putenv()
,除非我启用了安全模式,否则这将不起作用,我不想这样做;我也尝试过 apache_setenv()
,但似乎也没有起作用。
有没有其他解决方案我可能想尝试?
(我正在使用带有PHP 5.3.2的Linux机器)
如果您只想在特定情况下设置,可以执行以下操作:
exec (PATH = / my / path ./bin);
I am currently working on my own little project, but I have a little problem: I want to set the $PATH environment variable to ./bin
, so that when I use exec()
and similar functions, it would only search for binary files in that directory (unless I explicitly tell it otherwise).
I have already tried putenv()
, which won't work unless I have safe-mode enabled, which I'd prefer not to; and I also tried apache_setenv()
, but that didn't seem to work either.
Are there any other solutions I might want to try?
(I am using a Linux machine with PHP 5.3.2)
If you want to set it only in specific circumstances, you can do:
exec("PATH=/my/path ./bin");
这篇关于如何在PHP中设置$ PATH?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!