[PHP-DEV] creating an array in the extension From: Gustavo Badauy (gbadauy <email protected>)
Date: 08/15/00

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);

}

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>