# zend_class_entry.create_object

- Thread: https://externals.io/message/23105
- Original archive: https://news-web.php.net/php.internals/23105
- Started by Brandon Fosdick on 2006-05-03T06:24:41+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

---

## #23105 — Brandon Fosdick — 2006-05-03T06:24:41+00:00

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

When registering a new class, what are the consequences of setting zend_class_entry.create_object = NULL? INIT_CLASS_ENTRY() defaults it to NULL, but the tutorial I'm looking at sets it to the address of a function immediately afterwards. 

My concern is that setting this allows the engine to call a constructor-like-function behind my back. I'd rather handle such things while handling calls to new(). Is that possible? Is it even a good idea?

The tutorial code provides a function for zend_class_entry.create_object that returns a populated zend_object_value. Presumably that's a useful thing to do, and if I don't have a function there I would need to find some other means of supplying the zend_object_value to the engine. Can I do that in a new() handler? How?

---

## #23113 — Marcus Boerger — 2006-05-03T07:39:02+00:00

URL: https://externals.io/message/23105#23113 · In reply to: #23105

Hello Brandon,

  create_object is your new handler that is supposed to deliver an empty
object. You cannot have this NULL. The __construct part allows to define
what the actual constructor does afterwards. Forcing __construct to be
called is a bit more complicated but a bunch of exts already do so. Check
out pdo on that.

regards
marcus

Wednesday, May 3, 2006, 8:24:41 AM, you wrote:

> When registering a new class, what are the consequences of setting
> zend_class_entry.create_object = NULL? INIT_CLASS_ENTRY() defaults it to
> NULL, but the tutorial I'm looking at sets it to the address of a function immediately afterwards.

> My concern is that setting this allows the engine to call a
> constructor-like-function behind my back. I'd rather handle such things
> while handling calls to new(). Is that possible? Is it even a good idea?

> The tutorial code provides a function for zend_class_entry.create_object
> that returns a populated zend_object_value. Presumably that's a useful
> thing to do, and if I don't have a function there I would need to find
> some other means of supplying the zend_object_value to the engine. Can I do that in a new() handler? How?




Best regards,
 Marcus
