3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $string = <<<XML <programme channel="cnn.info" start="20131027060000" stop="20131027061500"> <title>hello CONTENT</title> <premiere/></programme> XML; $xml = simplexml_load_string($string); $start = $xml->attributes()->start; $stop = $xml->attributes()->stop; $title = $xml->title; echo "Title: " . $title . "\n"; $datetime1 = new DateTime($start); $datetime2 = new DateTime($stop); $interval = $datetime1->diff($datetime2); echo $interval->format('Time left: %i minutes');
Output for 5.3.0 - 7.1.0
Title: hello CONTENT Time left: 15 minutes
Output for 5.2.0 - 5.2.17
Title: hello CONTENT Fatal error: Call to undefined method DateTime::diff() in /in/gDPTQ on line 16
Process exited with code 255.
Output for 5.0.0 - 5.1.1, 5.1.3 - 5.1.6
Title: hello CONTENT Fatal error: Class 'DateTime' not found in /in/gDPTQ on line 14
Process exited with code 255.
Output for 5.1.2
Title: hello CONTENT Fatal error: Class 'DateTime' not found in /in/gDPTQ on line 15
Process exited with code 255.
Output for 4.4.3 - 4.4.9
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/gDPTQ on line 10
Process exited with code 255.
Output for 4.4.2
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/gDPTQ on line 11
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/gDPTQ on line 10
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/gDPTQ on line 10
Process exited with code 255.