3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $html = <<<EOF <!doctype html> <html> <head> <link href='http://wendyandgabe.blogspot.com/favicon.ico' rel='icon' type='image/x-icon'/> <link href='http://wendyandgabe.blogspot.com/' rel='canonical'/> <link rel="alternate" type="application/atom+xml" title="O&#39; Happy Day! - Atom" href="http://wendyandgabe.blogspot.com/feeds/posts/default" /> <link rel="alternate" type="application/rss+xml" title="O&#39; Happy Day! - RSS" href="http://wendyandgabe.blogspot.com/feeds/posts/default?alt=rss" /> <link rel="service.post" type="application/atom+xml" title="O&#39; Happy Day! - Atom" href="http://www.blogger.com/feeds/5390468261501503598/posts/default" /> </head> <body> </body> </html> EOF; $xml = new DomDocument; $xml->loadXML($html); //create a xpath instance $xpath = new DomXpath($xml); //query for <sub name="Y"> and use the first found item $link = $xpath->query('//link[@type="application/rss+xml"]')->item(0); var_dump($link->getAttribute('href'));
Output for 7.0.0 - 7.1.0
Warning: DOMDocument::loadXML(): StartTag: invalid element name in Entity, line: 1 in /in/Nhhvd on line 19 Warning: DOMDocument::loadXML(): Extra content at the end of the document in Entity, line: 1 in /in/Nhhvd on line 19 Fatal error: Uncaught Error: Call to a member function getAttribute() on null in /in/Nhhvd:28 Stack trace: #0 {main} thrown in /in/Nhhvd on line 28
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
Warning: StartTag: invalid element name in Entity, line: 1 Warning: Extra content at the end of the document in Entity, line: 1 Fatal error: Uncaught exception 'BadMethodCallException' with message 'Call to a member function getAttribute() on a non-object (null)' in /in/Nhhvd:28 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.28
Warning: DOMDocument::loadXML(): StartTag: invalid element name in Entity, line: 1 in /in/Nhhvd on line 19 Warning: DOMDocument::loadXML(): Extra content at the end of the document in Entity, line: 1 in /in/Nhhvd on line 19 Fatal error: Call to a member function getAttribute() on null in /in/Nhhvd on line 28
Process exited with code 255.
Output for 5.0.0 - 5.1.1, 5.1.3 - 5.5.38
Warning: DOMDocument::loadXML(): StartTag: invalid element name in Entity, line: 1 in /in/Nhhvd on line 19 Warning: DOMDocument::loadXML(): Extra content at the end of the document in Entity, line: 1 in /in/Nhhvd on line 19 Fatal error: Call to a member function getAttribute() on a non-object in /in/Nhhvd on line 28
Process exited with code 255.
Output for 5.1.2
Warning: DOMDocument::loadXML(): StartTag: invalid element name in Entity, line: 1 in /in/Nhhvd on line 20 Warning: DOMDocument::loadXML(): Extra content at the end of the document in Entity, line: 1 in /in/Nhhvd on line 20 Fatal error: Call to a member function getAttribute() on a non-object in /in/Nhhvd on line 29
Process exited with code 255.
Output for 4.4.3 - 4.4.9
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/Nhhvd on line 25
Process exited with code 255.
Output for 4.4.2
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/Nhhvd on line 26
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_OBJECT_OPERATOR in /in/Nhhvd on line 25
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/Nhhvd on line 25
Process exited with code 255.