ID:               30778
 User updated by:  sagawa at sohgoh dot 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:

No.
SunOS (Solaris)'s putenv C function does not return -1, even received
argument is valiable name only (like "VAR").


Previous Comments:
------------------------------------------------------------------------

[2004-11-13 22:20:48] [EMAIL PROTECTED]

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 http://bugs.php.net/?id=30778&edit=1

Reply via email to