php_embed and call_user_function

php.internals

Phillip Whelan

21 years ago
Im trying to call call_user_function() from inside php_embed. It always returns FAILURE... Here is the .c file I am trying to use (minus the header files, for clarity...) int main(int argc, char **argv) { zval *func; zval *zret; void ***trsm_ls; if ( php_embed_init(1, argv PTSRMLS_CC) == FAILURE) { puts("Failed to load"); return; } MAKE_STD_ZVAL(func); MAKE_STD_ZVAL(zret); zend_eval_string("include('test.php');", NULL, "TEST"); func->type = IS_STRING; func->value.str.len = 4; func->value.str.val = "test"; call_user_function(CG(function_table),NULL,func,zret,0,NULL TSRMLS_CC); php_embed_shutdown(TSRMLS_C); } and here is a test php file: <?php function test() { print "Hello World\n"; } ?> I also did a direct zend_hash_find() on CG(function_table) and EG(function_table) for test, with no result.

Marcus Boerger

21 years ago
Hello Phillip, Saturday, March 12, 2005, 1:35:26 AM, you wrote:
> Im trying to call call_user_function() from inside php_embed. > It always returns FAILURE...
> Here is the .c file I am trying to use > (minus the header files, for clarity...)
> int main(int argc, char **argv) > { > zval *func; > zval *zret; > void ***trsm_ls; > > > if ( php_embed_init(1, argv PTSRMLS_CC) == FAILURE) { > puts("Failed to load"); > return; > } > MAKE_STD_ZVAL(func); > MAKE_STD_ZVAL(zret); > > zend_eval_string("include('test.php');", NULL, "TEST"); > > func->type = IS_STRING; > func->value.str.len = 4; > func->value.str.val = "test"; > > call_user_function(CG(function_table),NULL,func,zret,0,NULL TSRMLS_CC);
This should be EG(function_table) instead.
> > php_embed_shutdown(TSRMLS_C); > }
regards marcus