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



[PHP] Scope issue

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

Thanks

-- 
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



[PHP] scope issue?

2002-03-10 Thread Nick Wilson

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi, 
I have the solution to my problem here but can't see why i need it?

this snippet takes $AuthId from a form and but does not work (doesn't
seem to pass it to the function)

case edit:
$tips-get_author($AuthId);
$content=edit_author_form($tips-auth_id);
break;

but this works fine...

case edit:
$id=$AuthId;
$tips-get_author($id);
$content=edit_author_form($tips-auth_id);
break;

Why?

Many thanks

- -- 
- ---
 www.explodingnet.com   |Projects, Forums and
+Articles for website owners 
- -- Nick Wilson -- |and designers.

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.6 (GNU/Linux)

iD4DBQE8i5SQHpvrrTa6L5oRAuh7AKCmdRmslIv+sexSyW+vtuad8flu0wCXYaKt
bjROMlsgU5XtiZ2ewhybJQ==
=6ZTA
-END PGP SIGNATURE-

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