php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #3675 getenv("PATH") after putenv("PATH") doesn't show new value
Submitted: 2000-03-01 00:20 UTC Modified: 2000-03-05 11:48 UTC
From: bbrown at ibexa dot com Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 3.0.14 OS: HPUX 10.20, Solaris 7
Private report: No CVE-ID: None
 [2000-03-01 00:20 UTC] bbrown at ibexa dot com
I am running 3.0.15, but bug database form doesn't have that as an option.

I need to modify the PATH environment variable in my script. I get the current value with getenv("PATH"), then
modify it with putenv. If I do a subsequent getenv("PATH") to verify the change, it is not shown. phpinfo(), however,
shows the changed variable. But is it being made available to child processes?

The following script reproduces the problem on both HPUX 10.20 and Solaris 7 running Apache 1.3.12 with PHP as a DSO.

<? 
# Fetch PATH env var
$path = getenv("PATH");
echo $path . "<BR>\n";

# Append to the path
putenv("PATH=$path:/foo/bar");

# Print the changed path (?)
echo getenv("PATH") . "<BR>\n";

# phpinfo shows it correctly
phpinfo();
?>

The problem appears to only afflict the PATH variable; others work fine.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-03-05 11:48 UTC] sas at cvs dot php dot net
getenv() will fetch PATH from Apache's subprocess environment which does not reflect environment changes of the current process. Changes in the environment are passed to child processes.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Tue Oct 13 12:00:02 2026 UTC