douzhanjia0773 2011-02-15 09:55
浏览 81
已采纳

PHP system()如何导出PATH

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');

  • 写回答

3条回答 默认 最新

  • dqdes60666 2011-02-15 10:15
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作