Req #30778 [Opn->Csd]: need unset support for putenv

From: Date: Tue, 25 Jul 2017 15:42:07 +0000
Subject: Req #30778 [Opn->Csd]: need unset support for putenv
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-210322@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=30778&edit=1 ID: 30778 Updated by: kalle@php.net Reported by: sagawa at sohgoh dot net Summary: need unset support for putenv -Status: Open +Status: Closed Type: Feature/Change Request Package: PHP options/info functions Operating System: FreeBSD, SunOS PHP Version: 4.3.9 -Assigned To: +Assigned To: kalle Block user comment: N Private report: N New Comment: By inspecting the source, it seems like PHP has gained this ability in the recent years Previous Comments: ------------------------------------------------------------------------ [2004-12-16 07:27:21] sagawa at sohgoh dot net No. SunOS (Solaris)'s putenv C function does not return -1, even received argument is valiable name only (like "VAR"). ------------------------------------------------------------------------ [2004-11-13 22:20:48] tony2001@php.net 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. ------------------------------------------------------------------------ [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 https://bugs.php.net/bug.php?id=30778&edit=1

« previous php.bugs (#210322) next »