3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php //this code will append a &mobileapp to every https://example.com url and http://foobar.com url ob_start(); ?> <html> <head> </head> <body> <a href="http://foobar.com"> http://www.example.com/~hillybilly/foobar.php silly silly </body> </html> <?php $html = ob_get_clean(); $append = 'mobileapp'; $doc = new DOMDocument(); $doc->loadHTML($buffer); $xpath = new DOMXpath($doc); $elements = $xpath->query('//*[@href OR @src OR @action]'); if (!is_null($elements)) { foreach ($elements as $element) { switch ($element->nodeName) { case 'a': $element->setAttribute('href', $element->getAttribute('href') . $append); } } } echo $doc->saveHtml();
Output for 5.1.0 - 5.6.28, 7.0.0 - 7.1.0
Notice: Undefined variable: buffer in /in/oPuFL on line 18 Warning: DOMDocument::loadHTML(): Empty string supplied as input in /in/oPuFL on line 18 Warning: DOMXPath::query(): Invalid predicate in /in/oPuFL on line 23 Warning: DOMXPath::query(): Invalid expression in /in/oPuFL on line 23 Warning: Invalid argument supplied for foreach() in /in/oPuFL on line 25
Output for hhvm-3.12.0
Notice: Undefined variable: buffer in /in/oPuFL on line 18 Fatal error: Uncaught TypeError: Argument 1 passed to DOMDocument::_loadHTML() must be an instance of string, null given in /in/oPuFL:18 Stack trace: #0 /in/oPuFL(18): DOMDocument->loadHTML() #1 {main}
Process exited with code 255.
Output for hhvm-3.10.0
Notice: Undefined variable: buffer in /in/oPuFL on line 18 Warning: Empty string supplied as input Warning: Invalid argument supplied for foreach() in /in/oPuFL on line 30 XPath error : Invalid predicate //*[@href OR @src OR @action] ^ XPath error : Invalid expression //*[@href OR @src OR @action] ^
Output for 5.0.4 - 5.0.5
Notice: Undefined variable: buffer in /in/oPuFL on line 18 Warning: DOMDocument::loadHTML(): Empty string supplied as input in /in/oPuFL on line 18 Warning: Invalid predicate in /in/oPuFL on line 23 Warning: Invalid expression in /in/oPuFL on line 23 Warning: Invalid argument supplied for foreach() in /in/oPuFL on line 25
Output for 5.0.0 - 5.0.3
Notice: Undefined variable: buffer in /in/oPuFL on line 18 Warning: DOMDocument::loadHTML(): Empty string supplied as input in /in/oPuFL on line 18 Warning: Invalid predicate in /in/oPuFL on line 23 Warning: Invalid expression in /in/oPuFL on line 23 Warning: Invalid argument supplied for foreach() in /in/oPuFL on line 25
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: domdocument in /in/oPuFL on line 17
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: domdocument in /in/oPuFL on line 17