3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $dom = new DOMDocument(); $dom->loadHTML($buffer); foreach($doc->getElementsByTagName('img') as $tag) { $src = $tag->getAttribute('src'); $tag->setAttribute('data-src', '/images/blank.gif'); $tag->setAttribute('data-original', $src); } $buffer=$dom->saveHTML();
Output for 7.0.5 - 7.1.0
Notice: Undefined variable: buffer in /in/j11kH on line 3 Warning: DOMDocument::loadHTML(): Empty string supplied as input in /in/j11kH on line 3 Notice: Undefined variable: doc in /in/j11kH on line 6 Fatal error: Uncaught Error: Call to a member function getElementsByTagName() on null in /in/j11kH:6 Stack trace: #0 {main} thrown in /in/j11kH on line 6
Process exited with code 255.
Output for 7.0.0 - 7.0.4
Notice: Undefined variable: buffer in /in/j11kH on line 3 Warning: DOMDocument::loadHTML(): Empty string supplied as input in /in/j11kH on line 3 Notice: Undefined variable: doc in /in/j11kH on line 6 Fatal error: Uncaught Error: Call to a member function getElementsByTagName() on unknown in /in/j11kH:6 Stack trace: #0 {main} thrown in /in/j11kH on line 6
Process exited with code 255.
Output for 5.6.7 - 5.6.28
Notice: Undefined variable: buffer in /in/j11kH on line 3 Warning: DOMDocument::loadHTML(): Empty string supplied as input in /in/j11kH on line 3 Notice: Undefined variable: doc in /in/j11kH on line 6 Fatal error: Call to a member function getElementsByTagName() on null in /in/j11kH on line 6
Process exited with code 255.
Output for 5.0.4 - 5.5.35
Notice: Undefined variable: buffer in /in/j11kH on line 3 Warning: DOMDocument::loadHTML(): Empty string supplied as input in /in/j11kH on line 3 Notice: Undefined variable: doc in /in/j11kH on line 6 Fatal error: Call to a member function getElementsByTagName() on a non-object in /in/j11kH on line 6
Process exited with code 255.
Output for 5.0.0 - 5.0.3
Notice: Undefined variable: buffer in /in/j11kH on line 3 Warning: DOMDocument::loadHTML(): Empty string supplied as input in /in/j11kH on line 3 Notice: Undefined variable: doc in /in/j11kH on line 6 Fatal error: Call to a member function getElementsByTagName() on a non-object in /in/j11kH on line 6
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: domdocument in /in/j11kH on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: domdocument in /in/j11kH on line 2