# Earliest zend_eval_string can be called?

- Thread: https://externals.io/message/49762
- Original archive: https://news-web.php.net/php.internals/49762
- Started by Matthew C. Rice on 2010-09-17T21:37:00+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

---

## #49762 — Matthew C. Rice — 2010-09-17T21:37:00+00:00

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

Hello,

    I was wondering how early a zend_eval_string call can be made. 
Currently it works fine in a PHP_FUNCTION(), but was hoping to put it in 
a PHP_MINIT() in hopes of it just executing once.

    It seems PHP_MINIT() is too early, and is causing failures. I came 
across PHP_GINIT_FUNCTION(), but can't seem to find when its called 
exactly, but the same situation as PHP_MINIT() seems to be the case, 
where its too early.

    In short, I am wondering if there is any place I can put the 
zend_eval_string() call in hopes of it running just once, so its result 
could be retained throughout the module execution.


Matthew

---

## #49764 — Alexey Zakhlestin — 2010-09-18T10:52:38+00:00

URL: https://externals.io/message/49762#49764 · In reply to: #49762

> Hello,
>
>   I was wondering how early a zend_eval_string call can be made. Currently
> it works fine in a PHP_FUNCTION(), but was hoping to put it in a PHP_MINIT()
> in hopes of it just executing once.
>
>   It seems PHP_MINIT() is too early, and is causing failures. I came across
> PHP_GINIT_FUNCTION(), but can't seem to find when its called exactly, but
> the same situation as PHP_MINIT() seems to be the case, where its too early.
>
>   In short, I am wondering if there is any place I can put the
> zend_eval_string() call in hopes of it running just once, so its result
> could be retained throughout the module execution.

definitely, not earlier than PHP_RINIT(), which doesn't help you.
all php's "userland" code is executed in the sandbox and sandbox
exists between PHP_RINIT and PHP_RSHUTDOWN

the only way to execute userland code before serving requests is to
use long running process, which serves requests from userland.
That's what I do in http://github.com/indeyets/appserver-in-php

-- 
Alexey Zakhlestin
http://www.milkfarmsoft.com/
