Re: Implementing callbacks to class member functions

From: Date: Sat, 14 Aug 2004 00:49:48 +0000
Subject: Re: Implementing callbacks to class member functions
References: 1 2  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-1141@lists.php.net to get a copy of this message
Alan Knowles wrote:
lxr.php.net is your friend - as the other post mentioned it's the NULL parameter in your example
I need some help implementing callback to a member function of a class. I have succesfully used calls like call_user_function_ex( EG(function_table), NULL, func_name, &retval,1,args,0,NULL TSRMLS CC) where func_name is a function in php script. What I would like to do is call function func1() in code below. for e.g
Having looked through the source I think the following is possible:
<?php class xyz { function func1() { } } function func2(){ } $xyz = new xyz(); function_with_callback($var, array($xyz, "func1")); function_with_callback($var, array("xyz", "func1")); function_with_callback($var, "func2"); ?> and then in the module, use if(is_callable((zval*)arg, 0, &(char*)function_name)) { call_user_function(EG(function_table), NULL, session->callback, retval, 1, &hostarray TSRMLS_CC)); } to receive any of these. Am I wrong? Thanks, John

« previous php.pecl.dev (#1141) next »