Re: [PECL-DEV] Hi, i have a question on zend_eval_string
[email protected] (Alexey Zakhlestin) Wed, 12 May 2010 09:27:38 +0400
| Newsgroups | php.pecl.dev |
|---|---|
| Message-ID | <[email protected]> |
On 12.05.2010, at 6:56, xiangchao liu wrote:
> Hi:
>
> How can i call zend_eval_string() in PHP_MINIT_FUNCTION block?
>
> For some reason i want to register my PHP functions in PHP_MINIT_FUNCTION,
> so that i do not have to define them in my .php files. Just like:
>
> PHP_FUNCTION(if_is_nil) {
> zend_eval_string("function if_real_is_nil($value) {\
> return $value === nil;\
> }", NULL, "if_real_is_nil" TSRMLS_CC);
> }
>
> When i call if_is_nil, the function if_real_is_nil() is defined.so i can
> call it later.
>
> But, when i move zend_eval_string(...) to PHP_MINIT_FUNCTION block, compiler
> goes well, but can not apache can not load the module anymore.
>
> Is there anyone knows how to get this work?
>
> Thanks in advanced.
what stops you from defining if_real_is_nil as PHP_FUNCTION and writing it in C? That would be the proper way to do it.
zend_eval_string can't work in PHP_MINIT, as engine is not fully initialised yet