3v4l.org

run code in 300+ PHP versions simultaneously
<?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 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
Deprecated: Return type of values::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/O2SR4 on line 18
Output for 5.2.0 - 5.2.17, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30
Output for 7.3.33
string(4) "date" string(26) "2014-05-13 08:59:15.002522" string(13) "timezone_type" int(3) string(8) "timezone" string(3) "UTC"
Output for 7.3.32
string(4) "date" string(26) "2014-05-13 08:59:15.002000" string(13) "timezone_type" int(3) string(8) "timezone" string(3) "UTC"
Output for 7.3.31
string(4) "date" string(26) "2014-05-13 10:59:15.003350" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.3.30
string(4) "date" string(26) "2014-05-13 10:59:15.003654" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.3.29
string(4) "date" string(26) "2014-05-13 10:59:15.007659" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.3.28
string(4) "date" string(26) "2014-05-13 10:59:15.011444" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.3.27
string(4) "date" string(26) "2014-05-13 10:59:15.008736" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.3.26
string(4) "date" string(26) "2014-05-13 10:59:15.013999" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.3.25
string(4) "date" string(26) "2014-05-13 10:59:15.008676" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.3.24
string(4) "date" string(26) "2014-05-13 10:59:15.008666" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.3.23
string(4) "date" string(26) "2014-05-13 10:59:15.011489" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.3.21
string(4) "date" string(26) "2014-05-13 10:59:15.009698" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.3.20
string(4) "date" string(26) "2014-05-13 10:59:15.012471" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.3.19
string(4) "date" string(26) "2014-05-13 10:59:15.012184" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.3.18
string(4) "date" string(26) "2014-05-13 10:59:15.004625" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.3.17
string(4) "date" string(26) "2014-05-13 10:59:15.012029" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.3.16
string(4) "date" string(26) "2014-05-13 10:59:15.009427" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.3.12
string(4) "date" string(26) "2014-05-13 10:59:15.000243" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.2.33
string(4) "date" string(26) "2014-05-13 10:59:15.009128" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.2.32
string(4) "date" string(26) "2014-05-13 10:59:15.008742" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.2.31
string(4) "date" string(26) "2014-05-13 10:59:15.008900" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.2.30
string(4) "date" string(26) "2014-05-13 10:59:15.011830" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.2.29
string(4) "date" string(26) "2014-05-13 10:59:15.009904" 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 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 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.3.29, 5.4.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.0.0 - 5.0.5, 5.1.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.3.11, 4.4.0 - 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.

preferences:
243.06 ms | 401 KiB | 357 Q