3v4l.org

run code in 300+ PHP versions simultaneously
<?php class values implements Iterator { private $_data = null; // array or object private $_keys = array(); private $_key = false; public function __construct($data = null){ $this->_data = $data; } public function current(){ return $this->_data->{"{$this->_key}"}; } public function key(){ return $this->_key; } public function next(){ $this->_key = next($this->_keys); } public function rewind(){ $this->_keys = array(); foreach ($this->_data as $k => $v){ $this->_keys[] = $k; } $this->_key = reset($this->_keys); } public function valid(){ if (false === $this->_key){ return false; } return isset($this->_data->{"{$this->_key}"}); } } $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.6
Deprecated: Return type of values::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/kaZ3W on line 11 Deprecated: Return type of values::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/kaZ3W on line 17 Deprecated: Return type of values::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/kaZ3W on line 14 Deprecated: Return type of values::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/kaZ3W on line 27 Deprecated: Return type of values::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/kaZ3W on line 20
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 09:19:47.002172" 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 09:19:47.002477" 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 11:19:47.003663" 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 11:19:47.003624" 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 11:19:47.007161" 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 11:19:47.007094" 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 11:19:47.009093" 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 11:19:47.008604" 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 11:19:47.011432" 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 11:19:47.008625" 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 11:19:47.009418" 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 11:19:47.008567" 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 11:19:47.010369" 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 11:19:47.012472" 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 11:19:47.005624" 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 11:19:47.008385" 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 11:19:47.008206" 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 11:19:47.000187" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.3.0
string(4) "date" string(26) "2014-05-13 11:19:47.000203" 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 11:19:47.008875" 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 11:19:47.008542" 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 11:19:47.011339" 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 11:19:47.008756" 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 11:19:47.007876" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.2.13
string(4) "date" string(26) "2014-05-13 11:19:47.000153" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.2.12
string(4) "date" string(26) "2014-05-13 11:19:47.000202" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.2.11
string(4) "date" string(26) "2014-05-13 11:19:47.000180" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.2.10
string(4) "date" string(26) "2014-05-13 11:19:47.000148" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.2.9
string(4) "date" string(26) "2014-05-13 11:19:47.000209" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.2.8
string(4) "date" string(26) "2014-05-13 11:19:47.000164" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.2.7
string(4) "date" string(26) "2014-05-13 11:19:47.000223" 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 11:19:47.000192" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.2.5
string(4) "date" string(26) "2014-05-13 11:19:47.000205" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.2.4
string(4) "date" string(26) "2014-05-13 11:19:47.024941" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.2.3
string(4) "date" string(26) "2014-05-13 11:19:47.020310" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.2.2
string(4) "date" string(26) "2014-05-13 11:19:47.072278" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.2.1
string(4) "date" string(26) "2014-05-13 11:19:47.000204" 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 11:19:47.000149" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.1.25
string(4) "date" string(26) "2014-05-13 11:19:47.016169" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.1.24
string(4) "date" string(26) "2014-05-13 11:19:47.018485" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.1.23
string(4) "date" string(26) "2014-05-13 11:19:47.000200" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.1.22
string(4) "date" string(26) "2014-05-13 11:19:47.094104" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.1.21
string(4) "date" string(26) "2014-05-13 11:19:47.015754" 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 11:19:47.022215" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.1.19
string(4) "date" string(26) "2014-05-13 11:19:47.015157" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.1.18
string(4) "date" string(26) "2014-05-13 11:19:47.000146" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.1.17
string(4) "date" string(26) "2014-05-13 11:19:47.037798" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.1.16
string(4) "date" string(26) "2014-05-13 11:19:47.009416" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.1.15
string(4) "date" string(26) "2014-05-13 11:19:47.006264" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.1.14
string(4) "date" string(26) "2014-05-13 11:19:47.000162" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.1.13
string(4) "date" string(26) "2014-05-13 11:19:47.000155" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.1.12
string(4) "date" string(26) "2014-05-13 11:19:47.000156" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.1.11
string(4) "date" string(26) "2014-05-13 11:19:47.000194" 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 11:19:47.073995" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.1.9
string(4) "date" string(26) "2014-05-13 11:19:47.028963" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.1.8
string(4) "date" string(26) "2014-05-13 11:19:47.092315" 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 11:19:47.031905" 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 11:19:47.009937" 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 11:19:47.045116" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.1.4
string(4) "date" string(26) "2014-05-13 11:19:47.032185" 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.21, 5.5.23 - 5.5.38, 5.6.0 - 5.6.38, 7.0.0 - 7.0.33, 7.1.3
string(4) "date" string(26) "2014-05-13 11:19:47.000000" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.1.2
string(4) "date" string(26) "2014-05-13 11:19:47.000198" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 7.1.1
string(4) "date" string(26) "2014-05-13 11:19:47.014372" 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 11:19:47.000185" string(13) "timezone_type" int(3) string(8) "timezone" string(16) "Europe/Amsterdam"
Output for 5.5.22
string(4) "date" string(26) "2014-05-13 11:19:48.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 11:19:47" 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/kaZ3W on line 35
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting '{' in /in/kaZ3W 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/kaZ3W on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `'{'' in /in/kaZ3W on line 3
Process exited with code 255.

preferences:
272.15 ms | 401 KiB | 424 Q