note 76927 rejected from function.simplexml-element-addChild by bobby
| From: | bobby@php.net | Date: | Mon, 06 Aug 2007 14:39:50 +0000 |
| Subject: | note 76927 rejected from function.simplexml-element-addChild by bobby | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-129226@lists.php.net to get a copy of this message | ||
Note Submitter: martin dot partel at mbnet dot fi
----
Curiously, addChild won't work on a child element that hasn't been set.
<?php
// php 5.2.3
error_reporting(E_ALL | E_STRICT);
$e = new SimpleXMLElement('<root/>');
//$e->foo = ''; // Uncomment this and it'll work
$e->foo->addChild('bar'); // No effect, no warning
echo $e->asXML(); // No <foo>, no <bar>
?>