php3-list | 2000051
Date: 05/15/00
- Next message: Gibellini Paolo: "[PHP3] R: [PHP3] odbc behaviour (was odbc_result getting same row)"
- Previous message: Wico de Leeuw: "Re: [PHP3] Accessing global variables from within a class"
- Next in thread: Richard Lynch: "Re: [PHP3] Accessing global variables from within a class"
- Reply: Richard Lynch: "Re: [PHP3] Accessing global variables from within a class"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I have been having difficulty accessing global environmental variables like $PHP_SELF and $HTTP_USER_AGENT from within a class. Normally, to use these values in functions you have to specify them as 'global', but I get a parse error when I try declaring a global variable within a class definition.
Example:
class Globals {
global $PHP_SELF;
function show_self() {
print $PHP_SELF;
}
}
Results in parse error:
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}''
The only way I have been able to get around this is to define a CONSTANT outside the class definition.
Example:
define("PHP_SELF",$PHP_SELF);
class Globals {
function show_self() {
print $PHP_SELF;
}
}
This works, but seems less then optimal. Is there a way around this?
Thanks for your help.
--Vamsi Nath
http://php.vamsi.net
-- PHP 3 Mailing List <http://www.php.net/> To unsubscribe, send an empty message to php3-unsubscribe <email protected> To subscribe to the digest, e-mail: php3-digest-subscribe <email protected> To search the mailing list archive, go to: http://www.php.net/mailsearch.php3 To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Gibellini Paolo: "[PHP3] R: [PHP3] odbc behaviour (was odbc_result getting same row)"
- Previous message: Wico de Leeuw: "Re: [PHP3] Accessing global variables from within a class"
- Next in thread: Richard Lynch: "Re: [PHP3] Accessing global variables from within a class"
- Reply: Richard Lynch: "Re: [PHP3] Accessing global variables from within a class"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

