3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $body = '<div class="cModule myphotos"> <h3><span>My photos</span></h3> <ul class="cResetList cThumbList clrfix"> <li> <a href="/projects/mysportsjam/index.php/joom-social/103-shine/photos/photo?albumid=12#photoid=67" hidefocus="true" style="outline: none;"><img class="cAvatar jomNameTips cAvatar-sidebar" title="Uploaded by shine s" src="http://107.20.167.165/projects/mysportsjam/images/photos/103/12/thumb_05c0beeb8f0f32a08538dad7.jpg" alt="shine s"></a> </li> <li> <a href="/projects/mysportsjam/index.php/joom-social/103-shine/photos/photo?albumid=12#photoid=43" hidefocus="true" style="outline: none;"><img class="cAvatar jomNameTips cAvatar-sidebar" src="http://107.20.167.165/projects/mysportsjam/images/photos/103/12/thumb_c122ff8dafd2edeba377a1cd.jpg" alt="shine s" original-title="Uploaded by shine s"></a> </li> <li> <a href="/projects/mysportsjam/index.php/joom-social/103-shine/photos/photo?albumid=12#photoid=66" hidefocus="true" style="outline: none;"><img class="cAvatar jomNameTips cAvatar-sidebar" title="Uploaded by shine s" src="http://107.20.167.165/projects/mysportsjam/images/photos/103/12/thumb_9414b5dff6c8644d197ff684.jpg" alt="shine s"></a> </li> </ul> <div class="app-box-footer"> <a href="/projects/mysportsjam/index.php/joom-social/103-shine/photos" hidefocus="true" style="outline: none;">View all photos</a> </div> </div>'; $xml = new DOMDocument(); $xml->loadHTML($body); $nodes = $xml->getElementsByTagName('li'); for($curr = 0; $curr < $nodes->length; $curr++) { $li = $nodes->item($curr); print $li->nodeValue . "\n"; foreach($li->childNodes as $child) { $a = $child; var_dump($child); // $href = $a->getAttribute('href'); // print "{$href}\n"; } print "\n"; }
Output for 7.0.0 - 7.1.0
object(DOMText)#6 (19) { ["wholeText"]=> string(11) " " ["data"]=> string(11) " " ["length"]=> int(11) ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(11) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> NULL ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> NULL ["textContent"]=> string(11) " " } object(DOMElement)#7 (18) { ["tagName"]=> string(1) "a" ["schemaTypeInfo"]=> NULL ["nodeName"]=> string(1) "a" ["nodeValue"]=> string(0) "" ["nodeType"]=> int(1) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> string(22) "(object value omitted)" ["lastChild"]=> string(22) "(object value omitted)" ["previousSibling"]=> string(22) "(object value omitted)" ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> string(22) "(object value omitted)" ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> string(1) "a" ["baseURI"]=> NULL ["textContent"]=> string(0) "" } object(DOMText)#6 (18) { ["wholeText"]=> string(5) " " ["data"]=> string(5) " " ["length"]=> int(5) ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(5) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> NULL ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> NULL ["textContent"]=> string(5) " " } object(DOMText)#7 (19) { ["wholeText"]=> string(5) " " ["data"]=> string(5) " " ["length"]=> int(5) ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(5) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> NULL ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> NULL ["textContent"]=> string(5) " " } object(DOMElement)#6 (18) { ["tagName"]=> string(1) "a" ["schemaTypeInfo"]=> NULL ["nodeName"]=> string(1) "a" ["nodeValue"]=> string(0) "" ["nodeType"]=> int(1) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> string(22) "(object value omitted)" ["lastChild"]=> string(22) "(object value omitted)" ["previousSibling"]=> string(22) "(object value omitted)" ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> string(22) "(object value omitted)" ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> string(1) "a" ["baseURI"]=> NULL ["textContent"]=> string(0) "" } object(DOMText)#7 (18) { ["wholeText"]=> string(5) " " ["data"]=> string(5) " " ["length"]=> int(5) ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(5) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> NULL ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> NULL ["textContent"]=> string(5) " " } object(DOMText)#6 (19) { ["wholeText"]=> string(5) " " ["data"]=> string(5) " " ["length"]=> int(5) ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(5) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> NULL ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> NULL ["textContent"]=> string(5) " " } object(DOMElement)#7 (18) { ["tagName"]=> string(1) "a" ["schemaTypeInfo"]=> NULL ["nodeName"]=> string(1) "a" ["nodeValue"]=> string(0) "" ["nodeType"]=> int(1) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> string(22) "(object value omitted)" ["lastChild"]=> string(22) "(object value omitted)" ["previousSibling"]=> string(22) "(object value omitted)" ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> string(22) "(object value omitted)" ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> string(1) "a" ["baseURI"]=> NULL ["textContent"]=> string(0) "" } object(DOMText)#6 (18) { ["wholeText"]=> string(5) " " ["data"]=> string(5) " " ["length"]=> int(5) ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(5) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> NULL ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> NULL ["textContent"]=> string(5) " " }
Output for hhvm-3.10.0 - 3.13.2
object(DOMText)#6 (19) { ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(11) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> NULL ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> NULL ["textContent"]=> string(11) " " ["data"]=> string(11) " " ["length"]=> int(11) ["wholeText"]=> string(11) " " } object(DOMElement)#7 (18) { ["nodeName"]=> string(1) "a" ["nodeValue"]=> string(0) "" ["nodeType"]=> int(1) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> string(22) "(object value omitted)" ["lastChild"]=> string(22) "(object value omitted)" ["previousSibling"]=> string(22) "(object value omitted)" ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> string(22) "(object value omitted)" ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> string(1) "a" ["baseURI"]=> NULL ["textContent"]=> string(0) "" ["tagName"]=> string(1) "a" ["schemaTypeInfo"]=> NULL } object(DOMText)#8 (19) { ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(5) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> NULL ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> string(22) "(object value omitted)" ["nextSibling"]=> NULL ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> NULL ["textContent"]=> string(5) " " ["data"]=> string(5) " " ["length"]=> int(5) ["wholeText"]=> string(5) " " } object(DOMText)#12 (19) { ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(5) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> NULL ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> NULL ["textContent"]=> string(5) " " ["data"]=> string(5) " " ["length"]=> int(5) ["wholeText"]=> string(5) " " } object(DOMElement)#13 (18) { ["nodeName"]=> string(1) "a" ["nodeValue"]=> string(0) "" ["nodeType"]=> int(1) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> string(22) "(object value omitted)" ["lastChild"]=> string(22) "(object value omitted)" ["previousSibling"]=> string(22) "(object value omitted)" ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> string(22) "(object value omitted)" ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> string(1) "a" ["baseURI"]=> NULL ["textContent"]=> string(0) "" ["tagName"]=> string(1) "a" ["schemaTypeInfo"]=> NULL } object(DOMText)#14 (19) { ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(5) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> NULL ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> string(22) "(object value omitted)" ["nextSibling"]=> NULL ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> NULL ["textContent"]=> string(5) " " ["data"]=> string(5) " " ["length"]=> int(5) ["wholeText"]=> string(5) " " } object(DOMText)#18 (19) { ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(5) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> NULL ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> NULL ["textContent"]=> string(5) " " ["data"]=> string(5) " " ["length"]=> int(5) ["wholeText"]=> string(5) " " } object(DOMElement)#19 (18) { ["nodeName"]=> string(1) "a" ["nodeValue"]=> string(0) "" ["nodeType"]=> int(1) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> string(22) "(object value omitted)" ["lastChild"]=> string(22) "(object value omitted)" ["previousSibling"]=> string(22) "(object value omitted)" ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> string(22) "(object value omitted)" ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> string(1) "a" ["baseURI"]=> NULL ["textContent"]=> string(0) "" ["tagName"]=> string(1) "a" ["schemaTypeInfo"]=> NULL } object(DOMText)#20 (19) { ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(5) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> NULL ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> string(22) "(object value omitted)" ["nextSibling"]=> NULL ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> NULL ["textContent"]=> string(5) " " ["data"]=> string(5) " " ["length"]=> int(5) ["wholeText"]=> string(5) " " }
Output for 5.3.11 - 5.3.29, 5.4.1 - 5.6.28
object(DOMText)#5 (19) { ["wholeText"]=> string(11) " " ["data"]=> string(11) " " ["length"]=> int(11) ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(11) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> NULL ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> NULL ["textContent"]=> string(11) " " } object(DOMElement)#7 (18) { ["tagName"]=> string(1) "a" ["schemaTypeInfo"]=> NULL ["nodeName"]=> string(1) "a" ["nodeValue"]=> string(0) "" ["nodeType"]=> int(1) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> string(22) "(object value omitted)" ["lastChild"]=> string(22) "(object value omitted)" ["previousSibling"]=> string(22) "(object value omitted)" ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> string(22) "(object value omitted)" ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> string(1) "a" ["baseURI"]=> NULL ["textContent"]=> string(0) "" } object(DOMText)#5 (18) { ["wholeText"]=> string(5) " " ["data"]=> string(5) " " ["length"]=> int(5) ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(5) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> NULL ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> NULL ["textContent"]=> string(5) " " } object(DOMText)#4 (19) { ["wholeText"]=> string(5) " " ["data"]=> string(5) " " ["length"]=> int(5) ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(5) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> NULL ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> NULL ["textContent"]=> string(5) " " } object(DOMElement)#5 (18) { ["tagName"]=> string(1) "a" ["schemaTypeInfo"]=> NULL ["nodeName"]=> string(1) "a" ["nodeValue"]=> string(0) "" ["nodeType"]=> int(1) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> string(22) "(object value omitted)" ["lastChild"]=> string(22) "(object value omitted)" ["previousSibling"]=> string(22) "(object value omitted)" ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> string(22) "(object value omitted)" ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> string(1) "a" ["baseURI"]=> NULL ["textContent"]=> string(0) "" } object(DOMText)#4 (18) { ["wholeText"]=> string(5) " " ["data"]=> string(5) " " ["length"]=> int(5) ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(5) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> NULL ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> NULL ["textContent"]=> string(5) " " } object(DOMText)#3 (19) { ["wholeText"]=> string(5) " " ["data"]=> string(5) " " ["length"]=> int(5) ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(5) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> NULL ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> NULL ["textContent"]=> string(5) " " } object(DOMElement)#4 (18) { ["tagName"]=> string(1) "a" ["schemaTypeInfo"]=> NULL ["nodeName"]=> string(1) "a" ["nodeValue"]=> string(0) "" ["nodeType"]=> int(1) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> string(22) "(object value omitted)" ["lastChild"]=> string(22) "(object value omitted)" ["previousSibling"]=> string(22) "(object value omitted)" ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> string(22) "(object value omitted)" ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> string(1) "a" ["baseURI"]=> NULL ["textContent"]=> string(0) "" } object(DOMText)#3 (18) { ["wholeText"]=> string(5) " " ["data"]=> string(5) " " ["length"]=> int(5) ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(5) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> NULL ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> NULL ["textContent"]=> string(5) " " }
Output for 5.0.0 - 5.3.10, 5.4.0
object(DOMText)#5 (0) { } object(DOMElement)#7 (0) { } object(DOMText)#5 (0) { } object(DOMText)#4 (0) { } object(DOMElement)#5 (0) { } object(DOMText)#4 (0) { } object(DOMText)#3 (0) { } object(DOMElement)#4 (0) { } object(DOMText)#3 (0) { }
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: domdocument in /in/5XFRa on line 24
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: domdocument in /in/5XFRa on line 24