Re: Calling other PHP functions from your extension

From: Date: Sun, 16 Jun 2002 16:29:54 +0000
Subject: Re: Calling other PHP functions from your extension
References: 1 2 3 4  Groups: php.dev 
Request: Send a blank email to php-dev+get-85259@lists.php.net to get a copy of this message
Well have you tried it?
No :) I just got your email last night and responded, I intended to try this morning.
Use the same example, and instead of putting "test_function", put "phpinfo", or any php function that doesn't take parameters, and see the result, it works!
I'll do that right now...yup, worked, thanks!
To pass parameters to the function you want to call, it's a bit more complicated. Take a look at the call_user_function declaration in zend_API.h, you will see that there is one field called "parameter_count" (that's easy to understand what this is for), and the next field is "params". Those are zvals, so it's easy, put the parameters in this array as zvals, set the correct parameter count and bingo. Note that the documentation is WRONG. The call to call_user_function_ex is incorrect, it doesn't have the right number of parameters. For your case, you'd better go with call_user_function for now, not the "ex" one. Also, it should read TSRMLS_FETCH, not TSRMSLS_FETCH (don't forget this macro or you will loose the thread safe context).
And thanks for the additional head's up! I had to go read the zend api headers to get it working -- I think you're rigyt, call_user_function() is sufficient for me in this case. I just got phpinfo() working, I'll try getting eval() going in a few minutes. Thanks again for the help? Wood Shavings! Andrew Patterson

« previous php.dev (#85259) next »