Hi,
I'm trying to call a function inside a module, a PHP_FUNCTION.
Other than zend_eval_stringl, what's the direct way to do it?
--
Best Regards,
Aaron Lewis - PGP: 0x13714D33 - http://pgp.mit.edu/
Finger Print: 9F67 391B B770 8FF6 99DC D92D 87F6 2602 1371 4D33
Hi,
Hi,
I'm trying to call a function inside a module, a PHP_FUNCTION.
Other than zend_eval_stringl, what's the direct way to do it?
Please refer to call_user_function and call_user_function_ex.--
Best Regards,
Aaron Lewis - PGP: 0x13714D33 - http://pgp.mit.edu/
Finger Print: 9F67 391B B770 8FF6 99DC D92D 87F6 2602 1371 4D33--
cheers,
Wei Dai
Hi,
Hi,
I'm trying to call a function inside a module, a PHP_FUNCTION.
Other than zend_eval_stringl, what's the direct way to do it?
Please refer to call_user_function and call_user_function_ex.
...and along these lines, when you need to do something that is done
in other parts of the codebase, take a look at how those other parts
do them - searching lxr for "call_user_func" led me straight to
http://lxr.php.net/xref/PHP_5_6/ext/standard/basic_functions.c#4738
;-)
Hi,
Hi,
I'm trying to call a function inside a module, a PHP_FUNCTION.
Other than zend_eval_stringl, what's the direct way to do it?
Please refer to call_user_function and call_user_function_ex.
See also the set of zend_call_method_with_[0-4]_params macros in
zend_interfaces.h. Those allow to cache the function pointer (or use the
one provided via "f" option by zend_parse_parameters) and therefore
saving repeated lookups.
But general comment: Do you really want to call a user function? - This
might be the case when using callbacks, typically when this question
pops up the aim is to call some PHP provided function, then often there
is a better C level API ... going via PHP function is cumbersome and
"slow".
johannes
I'm trying to call a function inside a module, a PHP_FUNCTION.
Other than zend_eval_stringl, what's the direct way to do it?
Please refer to call_user_function and call_user_function_ex.
Actually, you need to be careful with this. If you are calling another
PHP function in the same extension, do not use call_user_function.
Instead, create a common C function that you can call from whereever you
need to. call_user_function(_ex) is not fast.
cheers,
Derick
--
http://derickrethans.nl | http://xdebug.org
Like Xdebug? Consider a donation: http://xdebug.org/donate.php
twitter: @derickr and @xdebug
Posted with an email client that doesn't mangle email: alpine
Hi Derick,
I'm trying to call a function inside a module, a PHP_FUNCTION.
Other than zend_eval_stringl, what's the direct way to do it?
Please refer to call_user_function and call_user_function_ex.
Actually, you need to be careful with this. If you are calling another
PHP function in the same extension, do not use call_user_function.
Instead, create a common C function that you can call from whereever you
need to. call_user_function(_ex) is not fast.
i agree.
here is a scenario:
i was wrote an extension, and i need to call some PHP function like “strtr (http://lxr.php.net/s?defs=strtr&project=PHP_5_4)” “*trim" or a function in
another extension but it doesn’t have a common C function. However, i don’t want to copy the implement
code into my extension.
so, i have two options:
- copy the duplicate code into my extension, It can be fast in this way, but the code is not beautiful.
- call call_user_function(_ex) , it’s slower than the first option, but the code is more simple and beautiful than the first option.
cheers,
Wei Dai
I'm trying to call a function inside a module, a PHP_FUNCTION.
Other than zend_eval_stringl, what's the direct way to do it?
Please refer to call_user_function and call_user_function_ex.Actually, you need to be careful with this. If you are calling
another PHP function in the same extension, do not use
call_user_function. Instead, create a common C function that you
can call from whereever you need to. call_user_function(_ex) is not
fast.i agree.
here is a scenario:
i was wrote an extension, and i need to call some PHP function like
“strtr (http://lxr.php.net/s?defs=strtr&project=PHP_5_4)” “*trim" or
a function in another extension but it doesn’t have a common C
function. However, i don’t want to copy the implement code into my
extension.so, i have two options:
copy the duplicate code into my extension, It can be fast in this
way, but the code is not beautiful.call call_user_function(_ex) , it’s slower than the first option,
but the code is more simple and beautiful than the first option.
or:
- refactor the functionality in PHP so that trim or others can be
used in extensions.
I would not pick option 2, especially not if you're going to call this
function a lot. Calling a PHP function directly involves a lot more
overhead than just calling a C-function.
cheers,
Derick
--
http://derickrethans.nl | http://xdebug.org
Like Xdebug? Consider a donation: http://xdebug.org/donate.php
twitter: @derickr and @xdebug
Posted with an email client that doesn't mangle email: alpine
so, i have two options:
copy the duplicate code into my extension, It can be fast in this
way, but the code is not beautiful.call call_user_function(_ex) , it’s slower than the first option,
but the code is more simple and beautiful than the first option.or:
- refactor the functionality in PHP so that trim or others can be
used in extensions.
Best option, while not possible for existing releases, a good example (trim):
http://lxr.php.net/xref/phpng/ext/standard/string.c#784
Cheers,
Pierre
@pierrejoye | http://www.libgd.org
so, i have two options:
copy the duplicate code into my extension, It can be fast in this
way, but the code is not beautiful.call call_user_function(_ex) , it’s slower than the first option,
but the code is more simple and beautiful than the first option.or:
- refactor the functionality in PHP so that trim or others can be
used in extensions.Best option, while not possible for existing releases, a good example (trim):
trim is just an example, we can call it 'x'.
x is a php function and it doesn't have a common C api.
so, i have two options:
copy the duplicate code into my extension, It can be fast in this
way, but the code is not beautiful.call call_user_function(_ex) , it’s slower than the first option,
but the code is more simple and beautiful than the first option.or:
- refactor the functionality in PHP so that trim or others can be
used in extensions.Best option, while not possible for existing releases, a good example
(trim):http://lxr.php.net/xref/phpng/ext/standard/string.c#784
trim is just an example, we can call it 'x'.
x is a php function and it doesn't have a common C api.
Yes, just pointing you at how it could be done, for functions not
exposed as a C API.
--
Pierre
@pierrejoye | http://www.libgd.org
I'm trying to call a function inside a module, a PHP_FUNCTION.
Other than zend_eval_stringl, what's the direct way to do it?Please refer to call_user_function and call_user_function_ex.
Actually, you need to be careful with this. If you are calling
another PHP function in the same extension, do not use
call_user_function. Instead, create a common C function that you
can call from whereever you need to. call_user_function(_ex) is not
fast.i agree.
here is a scenario:
i was wrote an extension, and i need to call some PHP function like
“strtr (http://lxr.php.net/s?defs=strtr&project=PHP_5_4)” “*trim" or
a function in another extension but it doesn’t have a common C
function. However, i don’t want to copy the implement code into my
extension.so, i have two options:
copy the duplicate code into my extension, It can be fast in this
way, but the code is not beautiful.call call_user_function(_ex) , it’s slower than the first option,
but the code is more simple and beautiful than the first option.or:
- refactor the functionality in PHP so that trim or others can be
used in extensions.I would not pick option 2, especially not if you're going to call this
function a lot. Calling a PHP function directly involves a lot more
overhead than just calling a C-function.
you are right.
the reason to write php extension, because we can get performance improvement.
cheer,
Wei Dai