Re: Best way to access $_SERVER variables from c?
| From: | Pierre | Date: | Tue, 21 Nov 2006 02:21:20 +0000 |
| Subject: | Re: Best way to access $_SERVER variables from c? | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-26691@lists.php.net to get a copy of this message | ||
Hi Glenn,
On 11/21/06, Glenn Richmond <glenn.richmond@ilisys.com.au> wrote:
ok, worked it out - after a day and a half of trying to get it working,
it hits me just after I post! Didn't realize the values were coming back
as php hashes. For future newbie reference, here's the working code:
zval **server_name = NULL;
char* lookup_server_name;
if (strcmp(basedir, "VIRTUAL_DOCUMENT_ROOT") == 0) {
if (!PG(http_globals)[TRACK_VARS_SERVER] ||
zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht,
"SERVER_NAME", sizeof("SERVER_NAME"), (void **) &server_name) == FAILURE)
You can use the HASH_OF macro, a bit cleaner :
if (zend_hash_find(HASH_OF(PG(http_globals)[TRACK_VARS_SERVER]),
"SERVER_NAME", sizeof("SERVER_NAME"), (void **) &server_name) ==
SUCCESS) {
...
}
--Pierre