Re: php newbie, losing variable scope across functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Umm..

I think you want the global keyword...

function getparams()
{
global $smenu;
...
}


-- 
// DvDmanDT
MSN: dvdmandt¤hotmail.com
Mail: dvdmandt¤telia.com
<bry@xxxxxxxxxx> skrev i meddelandet news:200404041953125.SM01828@xxxxxxxx
> 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.

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux