# zend_compile_string() usage within code

- Thread: https://externals.io/message/60686
- Original archive: https://news-web.php.net/php.internals/60686
- Started by Clint Priest on 2012-05-29T03:10:24+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #60686 — Clint Priest — 2012-05-29T03:10:24+00:00

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

Has anyone ever used the zend_compile_string() within the c code for compiling internally created php?  Is it frowned upon or has it never come up before?

In writing the accessors code I have several parts that are effectively just mimicking what a simple zend_compile_string() would accomplish in a single line.  It may be just as efficient as writing the zend_do_begin_variable_parse() ... etc lines myself but would have the added benefit of changing as the language changed as well.

More specific example:

Automatic implementation for a getter, would be something like this:

public $a {
                get;  /* Equivalent to "return $this->__a */
                set;  /* Equivalent to "$this->__a = $value; */
}

I would simply CG(active_op_array) = zend_compile_string("return $this->__a;", ...);

Thoughts?

-Clint
