开发者

Modifying $PATH for PHP system() calls

开发者 https://www.devze.com 2023-02-14 09:55 出处:网络
I need to modify the $PATH on my mac so that PHP system() calls will recognize it. So far I\'ve edit开发者_如何学Ced the /etc/profile to include the line:

I need to modify the $PATH on my mac so that PHP system() calls will recognize it.

So far I've edit开发者_如何学Ced the /etc/profile to include the line:

export PATH=$PATH:/Applications/MAMP/Library/bin

but if I do system('echo $PATH'); in PHP the new path doesn't show up.


Use the putenv function. For example, to add the current directory to the $PATH, one could use the following code :

<?php
putenv('PATH='.getenv('PATH').':.');   
echo shell_exec('echo $PATH'); /* Prints the expected result */

http://php.net/putenv

0

精彩评论

暂无评论...
验证码 换一张
取 消