#30778 [Opn]: need unset support for putenv

From: Date: Sat, 13 Nov 2004 21:20:49 +0000
Subject: #30778 [Opn]: need unset support for putenv
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-69020@lists.php.net to get a copy of this message
ID: 30778 Updated by: tony2001@php.net Reported By: sagawa at sohgoh dot net Status: Open Bug Type: Feature/Change Request Operating System: FreeBSD, SunOS PHP Version: 4.3.9 New Comment: Just as a comment: It seems that only Linux supports unsetting env vars with putenv("VAR") and under others OSes putenv() fails with -1 in this case. Previous Comments: ------------------------------------------------------------------------ [2004-11-13 21:44:57] sagawa at sohgoh dot net Description: ------------ PHP doesn't support unsetenv, therefore I can't unset environment variable. On Linux box, putenv C function supports putenv("FOO") syntax that vanish FOO environment variable. But other OS (such as SunOS, FreeBSD) is not. Therefore please add putenv("FOO") feature to others in PHP5. Note: please distinguish empty variable (= getenv returns "") from undefined one (= getenv returns false). Reproduce code: --------------- <?php echo "OS: ",PHP_OS,"\n"; echo "foo is "; var_dump(getenv("FOO")); echo "---\n"; echo "putenv(\"FOO=bar\"): "; var_dump(putenv("FOO=bar")); echo "foo is "; var_dump(getenv("FOO")); echo "---\n"; echo "putenv(\"FOO=baz\"): "; var_dump(putenv("FOO=baz")); echo "foo is "; var_dump(getenv("FOO")); echo "---\n"; echo "putenv(\"FOO\"): "; var_dump(putenv("FOO")); echo "foo is "; var_dump(getenv("FOO")); ?> Expected result: ---------------- % php envtest.php OS: Linux foo is bool(false) --- putenv("FOO=bar"): bool(true) foo is string(3) "bar" --- putenv("FOO=baz"): bool(true) foo is string(3) "baz" --- putenv("FOO"): bool(true) foo is bool(false) % env FOO=foo php envtest.php OS: Linux foo is string(3) "foo" --- putenv("FOO=bar"): bool(true) foo is string(3) "bar" --- putenv("FOO=baz"): bool(true) foo is string(3) "baz" --- putenv("FOO"): bool(true) foo is bool(false) Actual result: -------------- % php envtest.php OS: FreeBSD foo is bool(false) --- putenv("FOO=bar"): bool(true) foo is string(3) "bar" --- putenv("FOO=baz"): bool(true) foo is string(3) "baz" --- putenv("FOO"): bool(false) foo is bool(false) % env FOO=foo php envtest.php OS: FreeBSD foo is string(3) "foo" --- putenv("FOO=bar"): bool(true) foo is string(3) "bar" --- putenv("FOO=baz"): bool(true) foo is string(3) "baz" --- putenv("FOO"): bool(false) foo is string(3) "baz" % php envtest.php OS: SunOS foo is bool(false) --- putenv("FOO=bar"): bool(true) foo is string(3) "bar" --- putenv("FOO=baz"): bool(true) foo is string(3) "baz" --- putenv("FOO"): bool(true) foo is bool(false) % env FOO=foo php envtest.php OS: SunOS foo is string(3) "foo" --- putenv("FOO=bar"): bool(true) foo is string(3) "bar" --- putenv("FOO=baz"): bool(true) foo is string(3) "baz" --- putenv("FOO"): bool(true) foo is string(3) "foo" ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=30778&edit=1

« previous php.bugs (#69020) next »