Re: Re: access to variables

From: Date: Tue, 24 Apr 2007 13:36:35 +0000
Subject: Re: Re: access to variables
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-28977@lists.php.net to get a copy of this message
Ci schrieb: > Stefan Esser napisał(a): >> Hello, >> >>> zend_hash_find(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), >>> "DOCUMENT ROOT", sizeof("DOCUMENT ROOT"), &data); >>> strcpy(buffer, Z_STRVAL_P(data); >> It is called DOCUMENT_ROOT, not DOCUMENT ROOT... > It was mistake in rewriting. If I choose any php variable, such as > DOCUMENT_ROOT, SERVER_NAME I got data in buffer like: '`5u', '1x'. > Is that method of getting variable correct? > No. The correct way for getting the variable is zval **data; ... if (zend_hash_find(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "DOCUMENT_ROOT", sizeof("DOCUMENT_ROOT"), &data)==SUCCESS) { ... strlcpy(buffer, Z_STRVAL_PP(data), sizeof(buffer)); } -sesser

« previous php.internals (#28977) next »