RE: [PHP-DEV] ? calling a module function from another module... From: Marc Boeren (M.Boeren <email protected>)
Date: 01/09/01

I've managed to call another modules function, including passing of
parameters...
Since I'm not really at home yet developing for PHP, could anyone give me
some advice, pointers, tips, do's and don'ts about the code I used to do
this???

[...]
    zval * parametername;
    zval * retval_ptr_ptr;
    zend_function_state function_state;
    int number_of_arguments;

    MAKE_STD_ZVAL(parametername);
    ZVAL_STRING(parametername, "localhost", 1);

    retval_ptr_ptr = NULL;

    if (zend_hash_find(&module_registry, "mysql", strlen("mysql")+1,
(void**)&module) == FAILURE) {
        return;
        }
    if (zend_hash_find(EG(function_table), "mysql_connect",
strlen("mysql_connect")+1, (void **) &function_state.function)==FAILURE) {
        zend_error(E_ERROR, "Unknown function: mysql_connect()\n");
        }

    zend_ptr_stack_push(&EG(arg_types_stack), NULL);

    number_of_arguments=1;
    zend_ptr_stack_n_push(&EG(argument_stack), number_of_arguments+2,
parametername, number_of_arguments, NULL);
    ALLOC_INIT_ZVAL(retval_ptr_ptr);
    ((zend_internal_function *)
function_state.function)->handler(number_of_arguments, retval_ptr_ptr, NULL,
1 ELS_CC);
[...]

Thanks, Marc.

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