Well, I kept playing with and got it to work. I changed the sizeof(AUTOGLOBAL_G(global_vars))-1 to strlen(AUTOGLOBAL_G(global_vars)).
Any reason not to use this. Brian. ----- Original Message ----- From: "Brian Moon" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, June 20, 2002 6:32 PM Subject: Re: [PHP-DEV] Custom Extensions and Super Globals | Ok, now for some help. | | I have this: | | PHP_MINIT_FUNCTION(autoglobal) | { | | ZEND_INIT_MODULE_GLOBALS(autoglobal, php_autoglobal_init_globals, NULL); | REGISTER_INI_ENTRIES(); | | zend_register_auto_global("_TEST2", sizeof("_TEST2")-1 TSRMLS_CC); | | if(sizeof(AUTOGLOBAL_G(global_vars))>0){ | | printf("value of global_vars in PHP_MINIT_FUNCTION: %s\n\n", | AUTOGLOBAL_G(global_vars)); | | zend_register_auto_global(AUTOGLOBAL_G(global_vars), | sizeof(AUTOGLOBAL_G(global_vars))-1 TSRMLS_CC); | } | | return SUCCESS; | } | | | $_TEST2 is auto globaled just fine. I have a php.ini file that contains: | | autoglobals.global_vars = "_TEST" | | I have the following PHP script: | | $_TEST="_TEST global var"; | $_TEST2="_TEST2 global var"; | | function test() | { | echo "inside: \n"; | print_r($_TEST); | echo "\n"; | print_r($_TEST2); | echo "\n\n"; | } | | echo "outside: \n"; | print_r($_TEST); | echo "\n"; | print_r($_TEST2); | echo "\n\n"; | | test(); | | | I get: | | value of global_vars in PHP_MINIT_FUNCTION: _TEST | | outside: | _TEST global var | _TEST2 global var | | inside: | | _TEST2 global var | | So, _TEST is getting read from the ini file, but it is not getting auto | globaled. I get no errors when compiling. | | Does anybody see the error? | | Brian. | | ----- Original Message ----- | From: "Brad LaFountain" <[EMAIL PROTECTED]> | To: "Brian Moon" <[EMAIL PROTECTED]> | Cc: <[EMAIL PROTECTED]> | Sent: Thursday, June 20, 2002 3:32 PM | Subject: Re: [PHP-DEV] Custom Extensions and Super Globals | | | | I believe you are looking for | | | | zend_register_auto_global(); | | | | - Brad | | --- Brian Moon <[EMAIL PROTECTED]> wrote: | | > I was just thinking about some of our code on dealnews.com and thought | it | | > would be cool if we could write our own extension that would, among | other | | > things, make a couple of widely used variables on out site super globals | | > like $_SERVER, etc. A) Can this be done. B) If so, can anybody give me | a | | > push in the right direction to making it happen? | | > | | > Thanks, | | > | | > Brian Moon | | > dealnews.com | | > Phorum.org | | > | | > | | > -- | | > PHP Development Mailing List <http://www.php.net/> | | > To unsubscribe, visit: http://www.php.net/unsub.php | | > | | | | | | __________________________________________________ | | Do You Yahoo!? | | Yahoo! - Official partner of 2002 FIFA World Cup | | http://fifaworldcup.yahoo.com | | | | -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php