Re: php newbie, losing variable scope across functions

From: Date: Sun, 04 Apr 2004 18:07:53 +0000
Subject: Re: php newbie, losing variable scope across functions
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-23363@lists.php.net to get a copy of this message
Umm.. I think you want the global keyword... function getparams() { global $smenu; ... } -- // DvDmanDT MSN: dvdmandt¤hotmail.com Mail: dvdmandt¤telia.com <bry@itnisk.com> skrev i meddelandet news:200404041953125.SM01828@Debug... > Hi, I have an application I'm transferring > to php. Right now I'm in the rough outlining > of functionality stage. The application has > a couple of include files: > > 1. site-defaults.php > 2. xml-functions.php > > and the application sets some last minute > variables in the php that includes the other > documents. > unfortunately when I refer to these > variables in the included documents they > don't resolve. So to try and get them to do > so i did the following in my xml- > functions.php > > $smenu = "default"; > function getparams(){ > > $params= "<params><param name='cssType'>"; > $params = $params . "Dynamic</param>"; > $params = $params . "<param > name='menuref'>" . > $smenu . "</param></params>"; > > > > return $params; > > } > > now at this point i would be happy if i > could > get the variable to resolve when declared in > the same file as the function which > references it. (I can of course get the > variable values if i put them into a > function that returns them when asked and > call that function, but that seems like it > shouldn't be the solution.) > > please note that the above example's line > breaking is done by my email program, if i > declare $smenu in the getparams function it > resolves fine. > > Also if anyone has any code to handle > getparams as a dom builder please pass it > along, as i will have to do that as some > point to complete the application's > funcionality.

« previous php.windows (#23363) next »