PHP 7.2.0 Release Candidate 4 Released

getenv

(PHP 4, PHP 5, PHP 7)

getenvGets the value of an environment variable

Description

string getenv ( string $varname [, bool $local_only = false ] )

Gets the value of an environment variable.

You can see a list of all the environmental variables by using phpinfo(). Many of these variables are listed within » RFC 3875, specifically section 4.1, "Request Meta-Variables".

Parameters

varname

The variable name.

local_only

Set to true to only return local environment variables (set by the operating system or putenv).

Return Values

Returns the value of the environment variable varname, or FALSE if the environment variable varname does not exist.

Changelog

Version Description
5.5.38, 5.6.24, 7.0.9 The local_only parameter has been added.

Notes

Warning

If PHP is running in a SAPI such as Fast CGI, this function will always return the value of an environment variable set by the SAPI, even if putenv() has been used to set a local environment variable of the same name. Use the local_only parameter to of an environment vlocally- ref='/manN. r putenv).<

Parameters

xarialrefsec xarial-539ss="pageps="methodExarial #1, even if nctitrong>getenvgetporm>

xarial- hp">lo"e>, or //fr2"> lor: #000000 dl> //fr2"> lor: #0000BB"lilt;?>hp
//fr2"> lor: #FF8000 d//ernal"Exarialernal"panernal"ofernal"name">nctbr /getenv //fr2"> lor: #0000BB"l$ipernal"etenv //fr2"> lor: #007700 d=ernal"etenv //fr2"> lor: #0000BB"lass="refname"> //fr2"> lor: #007700 d(efname"> //fr2"> lor: #DD0000 d'REMOTE_ADDR'efname"> //fr2"> lor: #007700 d);tbr /gebr /getenv //fr2"> lor: #FF8000 d//ernal"Orernal"toriayernal"panernal"aernal"Su (sl/en/sernal"($_SERVERernal"orernal"$_ENVctbr /getenv //fr2"> lor: #0000BB"l$ipernal"etenv //fr2"> lor: #007700 d=ernal"etenv //fr2"> lor: #0000BB"l$_SERVERetenv //fr2"> lor: #007700 d[efname"> //fr2"> lor: #DD0000 d'REMOTE_ADDR'efname"> //fr2"> lor: #007700 d];tbr /gebr /getenv //fr2"> lor: #FF8000 d//ernal"afe-ayernal"assernal"terernal"to oernal"ofernal"anernal" vlocally- ernal"to='/man,ernal"ignolassernal"wheanslernal"ebr /g//ernal"orernal"ncternal"iternal"wasernal"tssernal"byernal"aernal"Se sernal"orernal"hasernal"a> lor: #0000BB"l$ipernal"etenv //fr2"> lor: #007700 d=ernal"etenv //fr2"> lor: #0000BB"lass="refname"> //fr2"> lor: #007700 d(efname"> //fr2"> lor: #DD0000 d'REMOTE_ADDR'efname"> //fr2"> lor: #007700 d,ernal"etenv //fr2"> lor: #0000BB"l efname"> //fr2"> lor: #007700 d)ernal"?:ernal"etenv //fr2"> lor: #0000BB"lass="refname"> //fr2"> lor: #007700 d(efname"> //fr2"> lor: #DD0000 d'REMOTE_ADDR'efname"> //fr2"> lor: #007700 dctbr /getenv //fr2"> lor: #0000BB"l?>"etenvlocal_/form> a Bug

stdocl>eteen nctinmedocl>tion">putengetenv-notes">

Par

otlrefsec99134">ete"> vction.get"clearfix">Vu99134">get"cls="funct
up">Report a Bug"clearfix">Vd99134">get"cls="functeases/feeVphp'="">!ion.putenpanrnctio-vctidla="">">Report a Bug"clearfnotes"> virorefsecV99134"ases/fee72% likeh as ...">get"c38port a Bug < "cls="funct#99134"aul> eng.mrktomanutitrong>getaass=ning"> &> ;etaasearfnotes">dnk reles/fee2010-07-29 11:36las"method7 years agotitrong>get g>hp">lo"e>, or > w3.o> Tas Fast CGI, s Fpanftog(anuaarn> has$_SERVER, $_ENVc becapan ile="Add ss=s="param keyPHP thoan array case-insi.ph Capitn clad,me — hreflanilt;?>hp ass="refname"> —keyword d(efname"> gle"> tclass d'path'efname"> —keyword d) efname"> — hreflan?>"etenvlocal_/form>< otlrefsec119680">ete"> vction.get"clearfix">Vu119680">get"cls="funct
up">Report a Bug"clearfix">Vd119680">get"cls="functeases/feeVphp'="">!ion.putenpanrnctio-vctidla="">">Report a Bug"clearfnotes"> virorefsecV119680"ases/fee83% likeh as ...">get"c4port a Bug < "cls="funct#119680"aul> yw()a>titrong>getaass=ning">e&> ;etaasearfnotes">dnk reles/fee2016-08-02 12:10las"method1 year agotitrong>get g>hp">lo"e>, or > w3.o> Aame .php nc"paraconfpan youaiphp'vIf Pyouablvaeveh aat see l environmanue fromen "l/en"he value of a(en'ttp-_PROXY')c"parabi Gen> l/enPHP is>Inse value of .tbr /gebr /gIt>> n'ttp-_PROXY')les aout s.f (srosfi local_/form>< otlrefsec107421">ete"> vction.get"clearfix">Vu107421">get"cls="funct
up">Report a Bug"clearfix">Vd107421">get"cls="functeases/feeVphp'="">!ion.putenpanrnctio-vctidla="">">Report a Bug"clearfnotes"> virorefsecV107421"ases/fee67% likeh as ...">get"c17port a Bug < "cls="funct#107421"aul> >hp at kephp'/fr2r'="t anutitrong>getaass=ning">e&> ;etaasearfnotes">dnk reles/fee2012-02-08 12:51las"method5 years agotitrong>get g>hp">lo"e>, or > w3.o> Aee ment vlass=".php'exarial"sso facodeveha>In.tbr /gIle=houldmeGeste andt vlpanftoncessmenname">nc/ss="funcPHP CLIin awell.tbr /gebr /gss="parap!)nname">n"VAR") this reclaeveh aat tle">Gfrome> if t.tbr /gebr /gWeodeveha the opeby whichs.nPHPcludeha php'>ftoe menss="funcPste aif t"sstolassaconfigussing tle">sh aat paraernay hasmdifp'>Fut CLIiparas.fgrams. Bnk rfs.nPwanra"> inmer'>Gspan>. Mae">s,s.nPparaue same shell's (orlnvir>Imagrnate" typ,ning in aanr)he value of an environment by dosso.tbr /gebr /gTas Fseve FpaGfromep'vIf PhasmHumtype.pmouar menone-offaconfigussing nctions (saexecuing tiatcandline.php'argp?bugs;PHPe oads.nPjusts beeame grn.f envt/stroan e phest.ttenvlocal_/form>< otlrefsec39603">ete"> vction.get"clearfix">Vu39603">get"cls="funct
up">Report a Bug"clearfix">Vd39603">get"cls="functeases/feeVphp'="">!ion.putenpanrnctio-vctidla="">">Report a Bug"clearfnotes"> virorefsecV39603"ases/fee62% likeh as ...">get"c8port a Bug < "cls="funct#39603"aul> kyowarnem>titrong>getaass=ning">e&> ;etaasearfnotes">dnk reles/fee2004-02-04 01:06las"method13 years agotitrong>get g>hp">lo"e>, or > w3.o> Aamyouaknow, name">n'DOCUMENT_ROOT')ls Fpanfto.tbr /gHowever,sun>Ge CLIie value of (I me"na"> dos"show local_/form>< otlrefsec117022">ete"> vction.get"clearfix">Vu117022">get"cls="funct
up">Report a Bug"clearfix">Vd117022">get"cls="functeases/feeVphp'="">!ion.putenpanrnctio-vctidla="">">Report a Bug"clearfnotes"> virorefsecV117022"ases/fee60% likeh as ...">get"c5port a Bug < "cls="funct#117022"aul> hello at jaef="'="t rameem>titrong>getaass=ning">e&> ;etaasearfnotes">dnk reles/fee2015-04-03 06:47las"method2 years agotitrong>get g>hp">lo"e>, or > w3.o> Bewese aat whserve– i.il >hp -Sn envihost:8000 – it this recrame clae local_/form>< otlrefsec81771">ete"> vction.get"clearfix">Vu81771">get"cls="funct
up">Report a Bug"clearfix">Vd81771">get"cls="functeases/feeVphp'="">!ion.putenpanrnctio-vctidla="">">Report a Bug"clearfnotes"> virorefsecV81771"ases/fee57% likeh as ...">get"c4port a Bug < "cls="funct#81771"aul> sam at sambarrow'="t anutitrong>getaass=ning">e&> ;etaasearfnotes">dnk reles/fee2008-03-12 05:32las"method9 years agotitrong>get g>hp">lo"e>, or > w3.o> SERVER_NAMEls Ft vlaram faces.phimeter l/en/saconfigussing .tbr /gHtp-_HOSTls Ft vlhost > nnt variabcli>nntwh s ment vlp Suppletenvlocal_/form>< otlrefsec117301">ete"> vction.get"clearfix">Vu117301">get"cls="funct
up">Report a Bug"clearfix">Vd117301">get"cls="functeases/feeVphp'="">!ion.putenpanrnctio-vctidla="">">Report a Bug"clearfnotes"> virorefsecV117301"ases/fee54% likeh as ...">get"c1port a Bug < "cls="funct#117301"aul> >ritisn at gn/re'="t anutitrong>getaass=ning">e&> ;etaasearfnotes">dnk reles/fee2015-05-19 11:55las"method2 years agotitrong>get g>hp">lo"e>, or > w3.o> frna"show ncmete>Imag newstroan environ-tbr /grfsyouaeteen newstroan enviro,smncmthis recrameitial Ft vlaew tolter stroan enviroletenvlocal_/form>< otlrefsec97763">ete"> vction.get"clearfix">Vu97763">get"cls="funct
up">Report a Bug"clearfix">Vd97763">get"cls="functeases/feeVphp'="">!ion.putenpanrnctio-vctidla="">">Report a Bug"clearfnotes"> virorefsecV97763"ases/fee51% likeh as ...">get"c1port a Bug < "cls="funct#97763"aul> chunps="t reeve Fat gn/re'="t anutitrong>getaass=ning">e&> ;etaasearfnotes">dnk reles/fee2010-05-06 11:59las"method7 years agotitrong>get g>hp">lo"e>, or > w3.o> Whserveconfigmthis e .fent varife_m or_virowed_tit_vars tcrlealocal_/form>< otlrefsec121327">ete"> vction.get"clearfix">Vu121327">get"cls="funct
up">Report a Bug"clearfix">Vd121327">get"cls="functeases/feeVphp'="">!ion.putenpanrnctio-vctidla="">">Report a Bug"clearfnotes"> virorefsecV121327"ases/fee50% likeh as ...">get"c0port a Bug < "cls="funct#121327"aul> janguo at janguo ="t anutitrong>getaass=ning">e&> ;etaasearfnotes">dnk reles/fee2017-07-06 01:49las"method3d anths agotitrong>get g>hp">lo"e>, or > w3.o> Taelexarial I, how'to fallbanpspintroe Fatax.php l/en/ I, info".2:tbr /gebr /g=/sth-3.2$ e" tio.php.tbr /gepan> — hreflanilt;?>hptbr /gebr /g$ip efname"> —keyword d= efname"> — hreflanass="refname"> —keyword d(efname"> gle"> tclass d'REMOTE_ADDR'efname"> —keyword d, efname"> — hreflan efname"> —keyword d) ?: efname"> — hreflanass="refname"> —keyword d(efname"> gle"> tclass d'REMOTE_ADDR'efname"> —keyword d)
— hreflan?>"ebr /getenvbr /g=/sth-3.2$ /web/l/en/se"/im5 tio.php. >br /gC l/en/ilt;/b>":ernal"tax.php l/en/,sunexp sele ':'n'REMOTE_ADDR', ) ? name">n'REMOTE_ADDR', ) : name">n'REMOTE_ADDR')etenvlocal_/form>< otlrefsec92412">ete"> vction.get"clearfix">Vu92412">get"cls="funct
up">Report a Bug"clearfix">Vd92412">get"cls="functeases/feeVphp'="">!ion.putenpanrnctio-vctidla="">">Report a Bug"clearfnotes"> virorefsecV92412"ases/fee32% likeh as ...">get"c-18port a Bug < "cls="funct#92412"aul> f ="t h/en/dtn2Fat gnx ="t nettitrong>getaass=ning">e&> ;etaasearfnotes">dnk reles/fee2009-07-23 05:42las"method8 years agotitrong>get g>hp">lo"e>, or > w3.o> AFast CGI, recramIf Phaedes.php'adrcessmenc-titisitientbrowsrvecouldmlook likeh as : ebr /g tbr /gepan> — hreflanilt;?>hp ebr /getenv —keyword dast CGI, efname"> — hreflanassIPfrom>Deawardrencname"> —keyword d() { ebr /gernal"ternal"tefname"> — hreflan$ipSclass="type"> —keyword d=@efname"> — hreflanass="refname"> —keyword d(efname"> gle"> tclass d"Htp-_X_FORWARDED_FOR"efname"> —keyword d); ebr /gernal"ternal"tefname"> — hreflan$addr efname"> —keyword d= efname"> — hreflanexplde.phname"> —keyword d(efname"> gle"> tclass d","efname"> —keyword d,efname"> — hreflan$ipSclass="type"> —keyword d); ebr /gernal"ternal"trecrameefname"> — hreflan$addr="type"> —keyword d[efname"> — hreflansizeofphname"> —keyword d(efname"> gle"> hreflan$addr="type"> —keyword d)-efname"> gle"> hreflan1="type"> —keyword d]; ebr /g} ebr /getenv — hreflan?>" ebr /getenv(assIPfrom>Deawardre()) wouldmelocal_/form>< otlrefsec47247">ete"> vction.get"clearfix">Vu47247">get"cls="funct
up">Report a Bug"clearfix">Vd47247">get"cls="functeases/feeVphp'="">!ion.putenpanrnctio-vctidla="">">Report a Bug"clearfnotes"> virorefsecV47247"eles/fee26% likeh as ...">get"c-26port a Bug < "cls="funct#47247"eul> renko at ilt;es.pve>"virtm a-life ="t nettitrong>getaass=ning">e&> ;etaasearfnotes">dnk reles/fee2004-11-08 06:40las"method12 years agotitrong>get g>hp">lo"e>, or > w3.o> Taelast CGI, 'page=f'varnamen'REMOTE_ADDR'),abut $_SERVER["REMOTE_ADDR"]letenvlocal_/form>< >stdocl>eteen nctinmedocl>tion">d>ort a clearfi>![en
'aarnnti PHP Options/Info 'childi a> ss="function">les rt_​o/resertenv.php">E s/Involved ss="function">les rttenv.php">E s/Involved ss="function">E s/Involved ss="function">E s/Involved ss="function">dltenv.php">E s/Involved ss="function">E s/Involved ss="function">G-cycures.rereles/feegc_​onhp'>G_​oycure">gc_​onhp'>G_​oycuretenv.php">E s/Involved ss="function">gc_​disvirotenv.php">E s/Involved ss="function">gc_​enairotenv.php">E s/Involved ss="function">gc_​enairogtenv.php">E s/Involved ss="function">gc_​mem_​oen/setenv.php">E s/Involved ss="function">E s/Involved ss="function">E s/Involved ss="function">E s/Involved ss="function">E s/Involved ss="function">E s/Involved ss="function">E s/Involved ss="function">E s/Involved ss="function">E s/Involved ss="function">E s/Involved ss="function">E s/Involved ss="function">E s/Involved co sear ss="function">E s/Involved ss="function">E s/Involved ss="function">E s/Involved ss="function">E s/Involved ss="function">E s/Involved ss="function">E s/Involved ss="function">E s/Involved ss="function">E s/Involved ss="function">ini ​a E s/Involved ss="function">ini ​g ​allefnv.php">E s/Involved ss="function">ini ​g efnv.php">E s/Involved ss="function">ini ​realoreefnv.php">E s/Involved ss="function">ini ​s efnv.php">E s/Involved ss="function">E s/Involved ss="function">E s/Involved ss="function">E s/Involved ss="function">E s/Involved ss="function">E s/Involved ss="function">E s/Involved ss="function">E s/Involved ss="function">E s/Involved ss="function">E s/Involved ss="function">E s/Involved ss="function">E s/Involved ss="function"> nctionles/feess=nr> clss=vr> nv.php">E s/Involved ss="function">E s/Involved ss="function">E s/Involved ss="function">E s/Involved ss="function">E s/Involved ss="function">E s/Involved ss="function">E s/Involved ss="function"> -anuaarns.rereles/feevr> _​onuaarn">vr> _​onuaarn nv.php">E s/Involved ss="function">E s/Involved ss="function">E s/Involved ss="function"> nctionles/feezend ​nr> clzend ​nr> nv.php">E s/Involved s/Involved np'>G foot
Res/InvolvedRes/InvolvedRes/InvolvedRes/Involved al_/form>