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