3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class values implements IteratorAggregate { protected $iterator; public function __construct($objOrArr) { if(is_array($objOrArr)) { $this->iterator = new ArrayObject($objOrArr); } else if(is_object($objOrArr)) { $this->iterator = new ArrayObject(get_object_vars($objOrArr)); } else { throw new Exception('$objOrArray is neither an array or an object'); } } public function getIterator() { return $this->iterator; } } $values = new values(new DateTime()); foreach($values as $k => $v) { var_dump($k, $v); }
Output for 7.3.0beta1
string(4) "date" string(26) "2014-05-13 10:59:15.003433" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.3.0alpha1
string(4) "date" string(26) "2014-05-13 10:59:15.002458" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.2.6
string(4) "date" string(26) "2014-05-13 10:59:15.003796" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.2.0
string(4) "date" string(26) "2014-05-13 10:59:15.003954" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.1.20
string(4) "date" string(26) "2014-05-13 10:59:15.047040" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.1.10
string(4) "date" string(26) "2014-05-13 10:59:15.003012" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.1.7
string(4) "date" string(26) "2014-05-13 10:59:15.002774" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.1.6
string(4) "date" string(26) "2014-05-13 10:59:15.013279" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.1.5
string(4) "date" string(26) "2014-05-13 10:59:15.013204" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.1.0
string(4) "date" string(26) "2014-05-13 10:59:15.003569" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 5.4.30 - 5.4.45, 5.5.14 - 7.0.20
string(4) "date" string(26) "2014-05-13 10:59:15.000000" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 5.3.0 - 5.4.29, 5.5.0 - 5.5.13
string(4) "date" string(19) "2014-05-13 10:59:15" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 5.2.0 - 5.2.17
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/O2SR4 on line 23
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting '{' in /in/O2SR4 on line 3
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_STRING, expecting '{' in /in/O2SR4 on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `'{'' in /in/O2SR4 on line 3
Process exited with code 255.