diff --git a/Dotenv.php b/Dotenv.php
index 5d63a82c63c952665784304db43c9b3efcd63187..622dc13042b136a4ad6cb15a780109b28869aa3e 100644
--- a/Dotenv.php
+++ b/Dotenv.php
@@ -94,7 +94,7 @@ final class Dotenv {
    */
   public function receiveGlobal(string $key, string $prompt, string $default = ''): string {
     $key = strtoupper($key);
-    $value = getenv($key);
+    $value = $_ENV[$key] ?? getenv($key);
     if ($value === FALSE) {
       if (!empty($prompt) && $this->io->isInteractive()) {
         $value = $this->io->ask($prompt . ': ');
@@ -205,7 +205,7 @@ final class Dotenv {
    */
   private function replaceItemEnvironmentVariables(string $item, array $matches): string {
     foreach ($matches as $var) {
-      $value = getenv($var);
+      $value = $_ENV[$var] ?? getenv($var);
       if ($value === FALSE) {
         $value = '';
       }