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(function($buffer){ $append = 'mobileapp'; $doc = new DOMDocument(); $doc->loadHTML($buffer); $xpath = new DOMXpath($doc); $elements = $xpath->query('//*[@href OR @src OR @action]'); if (is_null($elements)) { //nothing to replace return $buffer; } foreach ($elements as $element) { } return $buffer; }); ?> <html> <head> </head> <body> http://foobar.com http://www.example.com/~hillybilly/foobar.php silly silly </body> </html> <?php ob_end_flush();
Output for 5.3.0 - 5.6.28, 7.0.0 - 7.1.0
<html> <head> </head> <body> http://foobar.com http://www.example.com/~hillybilly/foobar.php silly silly </body> </html>
Output for hhvm-3.10.0 - 3.12.0
Warning: Invalid argument supplied for foreach() in /in/PueTY on line 19 <html> <head> </head> <body> http://foobar.com http://www.example.com/~hillybilly/foobar.php silly silly </body> </html> XPath error : Invalid predicate //*[@href OR @src OR @action] ^ XPath error : Invalid expression //*[@href OR @src OR @action] ^
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in /in/PueTY on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION, expecting ')' in /in/PueTY on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/PueTY on line 3
Process exited with code 255.