|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2017-09-07 13:06 UTC] requinix@php.net
-Status: Open
+Status: Feedback
[2017-09-07 13:06 UTC] requinix@php.net
[2017-09-07 13:20 UTC] goetas at gmail dot com
-Status: Feedback
+Status: Open
[2017-09-07 13:20 UTC] goetas at gmail dot com
[2017-09-07 13:23 UTC] goetas at gmail dot com
[2017-09-28 15:08 UTC] goetas at gmail dot com
[2018-08-06 22:57 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 09:00:01 2025 UTC |
Description: ------------ currently the simplexml api exposes the SimpleXMLElement class when asking elements that does not exists in the XML dom, but some operations are inconsistent. $xml // instanceof \SimpleXMLElement $node = $xml->NOT_EXISTING_NODE_NAME; // instanceof \SimpleXMLElement $a = $node->attributes() // instanceof \SimpleXMLElement $b = $node->children() // instanceof \SimpleXMLElement $a->asXML() // works $a->count() // error $a->getName() // does not work // all the other method call will trigger the error Test script: --------------- <?php $xml = simplexml_load_string('<root/>'); var_dump($xml->NOT_EXISTING_NODE_NAME instanceof \SimpleXMLElement); $attributes = $xml->NOT_EXISTING_NODE_NAME->attributes(); var_dump(count($attributes)); Expected result: ---------------- bool(true) PHP Warning: count(): Node no longer exists in /home/goetas/test.php on line 7 int(0) Actual result: -------------- bool(true) PHP Warning: count(): Node no longer exists in /home/goetas/test.php on line 7 int(0)