php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #54030 getenv() docs don't say what getenv() returns if variable not found
Submitted: 2011-02-16 09:20 UTC Modified: 2011-06-12 01:35 UTC
From: petern at kol dot co dot nz Assigned: dtajchreber (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2011-02-16 09:20 UTC] petern at kol dot co dot nz
Description:
------------
---
From manual page: http://www.php.net/function.getenv
---

The getenv() docs don't tell us what getenv() returns if the requested environment variable doesn't exist.

They just say:
  "Returns the value of the environment variable varname, or FALSE on an error."

Mmmmmm.  But is the requested variable not existing classed an error?  Or not?  I personally don't think it is.  And that a return of NULL in this situation would be best.  But what actually happens?  Some clarification would be useful.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-06-12 01:33 UTC] dtajchreber@php.net
Automatic comment from SVN on behalf of dtajchreber
Revision: http://svn.php.net/viewvc/?view=revision&revision=312071
Log: Fixes bug #54030 - clarifies getenv() behavior if the environment variable does not exist. Patch by Matthew Fonda
 [2011-06-12 01:35 UTC] dtajchreber@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: dtajchreber
 [2011-06-12 01:35 UTC] dtajchreber@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

getenv() returns false if the environment variable doesn't exist. 

[1] http://lxr.php.net/opengrok/xref/PHP_5_3/ext/standard/basic_functions.c#3989
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 22:00:01 2026 UTC