# php_embed and call_user_function

- Thread: https://externals.io/message/15394
- Original archive: https://news-web.php.net/php.internals/15394
- Started by Phillip Whelan on 2005-03-12T00:35:26+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #15394 — Phillip Whelan — 2005-03-12T00:35:26+00:00

URL: https://externals.io/message/15394#15394

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.

---

## #15395 — Marcus Boerger — 2005-03-12T11:25:41+00:00

URL: https://externals.io/message/15394#15395 · In reply to: #15394

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
