From: Tomas V.V.Cox Date: Fri, 26 Jul 2002 10:18:28 +0000 (+0000) Subject: Workarround to the empty $_ENV X-Git-Tag: dev~163 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=edfb9d44e43f9a2baf4672ae3f9f8a594340e487;p=php Workarround to the empty $_ENV --- diff --git a/pear/System.php b/pear/System.php index f9699781f3..ab3a9642e1 100644 --- a/pear/System.php +++ b/pear/System.php @@ -389,24 +389,36 @@ class System */ function tmpdir() { - if (OS_WINDOWS){ - if (isset($_ENV['TEMP'])) { - return $_ENV['TEMP']; + if (OS_WINDOWS) { + if (System::_myenv('TEMP')) { + return System::_myenv('TEMP'); } - if (isset($_ENV['TMP'])) { - return $_ENV['TMP']; + if (System::_myenv('TMP')) { + return System::_myenv('TMP'); } - if (isset($_ENV['windir'])) { - return $_ENV['windir'] . '\temp'; + if (System::_myenv('windir')) { + return System::_myenv('windir') . '\temp'; } - return $_ENV['SystemRoot'] . '\temp'; + return System::_myenv('SystemRoot') . '\temp'; } - if (isset($_ENV['TMPDIR'])) { - return $_ENV['TMPDIR']; + if (System::_myenv('TMPDIR')) { + return System::_myenv('TMPDIR'); } return '/tmp'; } + /** + * (cox) I always get $_ENV empty in both Windows and Linux + * with all PHP version <= 4.2.1 + */ + function _myenv($var) + { + if (!empty($_ENV)) { + return isset($_ENV[$var]) ? $_ENV[$var] : false; + } + return getenv($var); + } + /** * The "type" command (show the full path of a command) *