summaryrefslogtreecommitdiff
path: root/ext/simplexml/simplexml.c
diff options
context:
space:
mode:
authorEtienne Kneuss <colder@php.net>2008-05-03 15:09:37 +0000
committerEtienne Kneuss <colder@php.net>2008-05-03 15:09:37 +0000
commit57b8e8394512e2b7c862011ff51d8063f8e96551 (patch)
tree4cfed5dbb176f10cc4cd7317d561e1c2b3e3c89a /ext/simplexml/simplexml.c
parent04929019d2797424081a85d48efb49be66a64334 (diff)
downloadphp-git-57b8e8394512e2b7c862011ff51d8063f8e96551.tar.gz
MFH: Fix #44484 (define SimpleXMLElement::__toString())
Diffstat (limited to 'ext/simplexml/simplexml.c')
-rw-r--r--ext/simplexml/simplexml.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c
index 692e867a06..37b2dd1092 100644
--- a/ext/simplexml/simplexml.c
+++ b/ext/simplexml/simplexml.c
@@ -1794,6 +1794,23 @@ static int sxe_object_cast(zval *readobj, zval *writeobj, int type TSRMLS_DC)
}
/* }}} */
+/* {{{ proto object SimpleXMLElement::__toString() U
+ Returns the string content */
+SXE_METHOD(__toString)
+{
+ zval *result;
+
+ ALLOC_INIT_ZVAL(result);
+
+ if (sxe_object_cast(getThis(), result, IS_STRING TSRMLS_CC) == SUCCESS) {
+ RETURN_ZVAL(result, 1, 1);
+ } else {
+ zval_ptr_dtor(&result);
+ RETURN_EMPTY_STRING();
+ }
+}
+/* }}} */
+
static int sxe_count_elements(zval *object, long *count TSRMLS_DC) /* {{{ */
{
php_sxe_object *sxe;
@@ -2412,6 +2429,7 @@ static const zend_function_entry sxe_functions[] = { /* {{{ */
SXE_ME(getName, NULL, ZEND_ACC_PUBLIC)
SXE_ME(addChild, NULL, ZEND_ACC_PUBLIC)
SXE_ME(addAttribute, NULL, ZEND_ACC_PUBLIC)
+ SXE_ME(__toString, NULL, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
};
/* }}} */