Re: [PHP] Scope issue

2004-12-20 Thread Richard Lynch
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.phpbr /;

 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



RE: [PHP] Scope issue

2004-12-17 Thread Mike
 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?
 

Are there any specific reasons that you need to set the variable to global
scope? 

It's typically recommended that unless you need to, to pass the variable
into the function and return the modified value if you plan on changing it. 

-M

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