Re: Scope issue

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

 



GH wrote:
> Hi I am having an issue with I think it is the scope of variables:
>
> I have a file that I am including which has the following"
>
> <?php
> // +----------------------------------------------------------------------
> // | PHP Source
> // +----------------------------------------------------------------------
> //
>
> echo "got language.php<br />";
>
> global $langauge;
> $language['project_name'] = "P.L.I.M.S";
> $language['sub_project_name'] = "DCR CC";
> ?>
>
> In my main file, I am attempting to from with in a function call
> $language['project_name'] and i am failing... can you offer any
> advice?

Unless you are *inside* of a function definition, 'global' makes no sense
whatsoever in PHP.

Get rid of it unless you are inside function body.

But in your main script *DO* put:
global $language;
inside of your function body -- That's where you need it to be.

You may also want to consider passing $language in as an argument to your
function.

Or, if it *MUST* be a global variable, use $LANGUAGE so that it stands out
in the rest of your script.

-- 
Like Music?
http://l-i-e.com/artists.htm

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux