Note the usage of Zend's
estrdup()
here. Of course, you can also use the predefined macro
ZVAL_STRING
:
ZVAL_STRING
accepts a third parameter that indicates whether the supplied
string contents should be duplicated (using
estrdup()
). Setting this parameter to
1
causes the string to be duplicated;
0
simply uses the supplied pointer for the variable contents. This
is most useful if you want to create a new variable referring to
a string that's already allocated in Zend internal memory.
Of course, there's a macro for this as well (
ZVAL_EMPTY_STRING
):