I want to change the default system $PATH var for the period of php script execution, but it for some reason fails.
Im trying the following:
<?php
$lastline = system('export PATH=$PATH:/customBin;',$return) OR die("why do i die all the time");
echo $lastline;
?>
But it obviously dies all the time. (tried on both RHEL & Debian linux distros, php version 5.3.xx, other system commands work fine (cat, ls, etc) neither of these work: export PATH=$PATH:/customBin; OR export PATH=$PATH:/customBin: OR export PATH=/customBin, all of these work in the shell tho..)
Any help is appreciated. thanks.
EDIT: Above code is wrong, solution is to use putenv('PATH=$PATH:/customBin');
You might have better luck using putenv to change environment variables from PHP. Just fetch the current value with getenv, add whatever you like and finally call putenv to alter the value.