Re: session variables in functions....

From: Date: Tue, 20 Nov 2001 11:38:33 +0000
Subject: Re: session variables in functions....
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-75227@lists.php.net to get a copy of this message
Make it global or pass it as an argument: function CurrentLang(){ global $HTTP_SESSION_VARS; $language = $HTTP_SESSION_VARS["LangID"]; echo($language); } Or: function CurrentLang($HTTP_SESSION_VARS){ $language = $HTTP_SESSION_VARS["LangID"]; echo($language); } -- Julio Nobrega No matter where you go, &this. "Wim Van Houts" <wim.van.houts@voxtron.com> wrote in message news:20011120105540.97876.qmail@pb1.pair.com... > Somebody knows why I cannot reach the $HTTP_SESSION_VARS in a function .... > > For example, why does this not output the "en-US" string three times: > > <? > session_register("LangID"); > $HTTP_SESSION_VARS["LangID"] = "en-US"; > echo($HTTP_SESSION_VARS["LangID"]); > echo("**"); > function CurrentLang(){ > $language = $HTTP_SESSION_VARS["LangID"]; > echo($language); > } > CurrentLang(); > echo("**"); > echo($HTTP_SESSION_VARS["LangID"]); > > ?> > >

« previous php.general (#75227) next »