creating an array in the extension

From: Date: Wed, 16 Aug 2000 00:00:06 +0000
Subject: creating an array in the extension
Groups: php.dev 
Request: Send a blank email to php-dev+get-29078@lists.php.net to get a copy of this message
Hi, I'm trying to create an array (using the code below) in my extension and make it available to the page (that called). This function creates two functions, myvar and myarray. From the php script I can read the valu of myvar and it returns 1234, but I cannot use myarray. When I try gettype($myarray), I get NULL. Does anyone knows why is this happening and what is wrong with it? I was successfull when I tried to return an array, doin array_init(return_value) and so on. Thanks PHP_FUNCTION(cs_testfunction) { int result; zval *data; zval ret_array; result = zend_hash_exists (EG(active_symbol_table), "myvar", strlen("myvar") + 1 ); // test if it exists result = array_init (&ret_array); // test if was successfull // copied from appendix B of PHP3 Manual result = zend_hash_update(EG(active_symbol_table), "myarray", strlen("myarray") +1, &ret_array, sizeof(zval), NULL); MAKE_STD_ZVAL(data); data->type = IS_LONG; data->value.lval = 1234; ZEND_SET_SYMBOL (EG(active_symbol_table),"myvar",data); }

« previous php.dev (#29078) next »