3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class CommandId { private $name; private $time; private $hash; public function __construct($name, $time = null, $hash = null) { $this->time = (float) $time ?: microtime(true); $this->name = trim($name); $this->hash = $hash ?: hash('crc32', rand(0, $this->time)); if (empty($this->name)) { throw new DomainException('Name must not be empty'); } } public static function fromString($idString) { $parts = explode('_', $idString); if (count($parts) != 3) { throw new DomainException("Unexpected format [$idString]"); } return new static($parts[0], $parts[1], $parts[2]); } public function name() { return $this->name; } public function time() { return $this->time; } public function equals(self $other) { return ($this->name == $other->name && $this->time == $other->time && $this->hash == $other->hash ); } public function __toString() { return implode('_', [$this->name, $this->time, $this->hash]); } } $one = new CommandId('foo'); var_dump((string) $one, $one->equals(CommandId::fromString((string) $one)));
Output for 7.4.1
string(28) "foo_1416314634.0003_cf08dadb" bool(false)
Output for 7.4.0
string(28) "foo_1416314634.0002_d32cb9ff" bool(false)
Output for 7.2.25, 7.3.13
string(28) "foo_1416314634.0003_a4a57587" bool(false)
Output for 7.3.12
string(28) "foo_1416314634.0003_8016ad30" bool(false)
Output for 7.3.11
string(28) "foo_1416314634.0003_b04d3b76" bool(false)
Output for 7.3.10
string(28) "foo_1416314634.0002_8c52e573" bool(false)
Output for 7.3.9
string(28) "foo_1416314634.0002_c2a29035" bool(false)
Output for 7.3.8
string(28) "foo_1416314634.0004_2dfe4443" bool(false)
Output for 7.3.7
string(28) "foo_1416314634.0003_82d41ba4" bool(false)
Output for 7.3.6
string(28) "foo_1416314634.0002_f564902d" bool(false)
Output for 7.3.5
string(28) "foo_1416314634.0003_f99d17f0" bool(true)
Output for 7.3.4
string(28) "foo_1416314634.0003_5474260a" bool(false)
Output for 7.3.3
string(28) "foo_1416314634.0002_76a74fc0" bool(false)
Output for 7.3.2
string(28) "foo_1416314634.0002_3551656c" bool(false)
Output for 7.3.1
string(28) "foo_1416314634.0004_235606ab" bool(false)
Output for 7.3.0
string(28) "foo_1416314634.0002_413d1731" bool(false)
Output for 7.2.26
string(28) "foo_1416314634.0003_7abc3014" bool(false)
Output for 7.2.9, 7.2.24
string(28) "foo_1416314634.0002_cd1745b7" bool(false)
Output for 7.2.23
string(28) "foo_1416314634.0002_de589799" bool(false)
Output for 7.2.22
string(28) "foo_1416314634.0002_8a5e0de8" bool(false)
Output for 7.2.21
string(28) "foo_1416314634.0004_83dedf0a" bool(false)
Output for 7.2.20
string(28) "foo_1416314634.0003_e855ebc5" bool(false)
Output for 7.2.19
string(28) "foo_1416314634.0002_f0673b66" bool(false)
Output for 7.2.18
string(28) "foo_1416314634.0003_faad5bb3" bool(false)
Output for 7.2.17
string(28) "foo_1416314634.0003_31c95d34" bool(false)
Output for 7.2.16
string(28) "foo_1416314634.0002_4a945bf2" bool(false)
Output for 7.2.15
string(28) "foo_1416314634.0002_f1591a28" bool(false)
Output for 7.2.14
string(28) "foo_1416314634.0002_86241456" bool(false)
Output for 7.2.13
string(28) "foo_1416314634.0003_aea7235c" bool(false)
Output for 7.2.12
string(28) "foo_1416314634.0002_3e9c1bc1" bool(false)
Output for 7.2.10 - 7.2.11
string(28) "foo_1416314634.0002_1d5e1220" bool(false)
Output for 7.2.8
string(28) "foo_1416314634.0002_9fe79f66" bool(false)
Output for 7.2.7
string(28) "foo_1416314634.0002_afaa8396" bool(false)
Output for 7.2.6
string(28) "foo_1416314634.0002_0bab0cfd" bool(false)
Output for 7.2.5
string(28) "foo_1416314634.0002_12ce7062" bool(false)
Output for 7.2.4
string(28) "foo_1416314634.0002_9d44d6c0" bool(false)
Output for 7.2.3
string(28) "foo_1416314634.0002_ecb7cf27" bool(false)
Output for 7.2.2
string(28) "foo_1416314634.0002_b557b02b" bool(false)
Output for 7.1.28, 7.2.1
string(28) "foo_1416314634.0003_04b8a191" bool(false)
Output for 7.2.0
string(28) "foo_1416314634.0003_8f743184" bool(true)
Output for 7.1.33
string(28) "foo_1416314634.0002_ead6dcb8" bool(false)
Output for 7.1.32
string(28) "foo_1416314634.0002_c20199ca" bool(false)
Output for 7.1.31
string(28) "foo_1416314634.0002_d60de16c" bool(false)
Output for 7.1.30
string(28) "foo_1416314634.0003_d26e2533" bool(false)
Output for 7.1.29
string(28) "foo_1416314634.0002_14a9077d" bool(false)
Output for 7.1.27
string(28) "foo_1416314634.0002_4891885b" bool(false)
Output for 7.1.26
string(28) "foo_1416314634.0002_56827854" bool(false)
Output for 7.1.25
string(28) "foo_1416314634.0002_123f16ad" bool(false)
Output for 7.1.24
string(28) "foo_1416314635.0002_b6dca942" bool(false)
Output for 7.1.23
string(28) "foo_1416314634.0002_11d9aa14" bool(false)
Output for 7.1.22
string(28) "foo_1416314634.0003_ad883919" bool(false)
Output for 7.1.21
string(28) "foo_1416314634.0002_8c426765" bool(false)
Output for 7.1.7, 7.1.20
string(28) "foo_1416314634.0002_1b236f51" bool(false)
Output for 7.1.19
string(28) "foo_1416314634.0003_ef5aecbf" bool(false)
Output for 7.1.1, 7.1.18
string(28) "foo_1416314634.0002_7b2bcda7" bool(false)
Output for 7.1.17
string(28) "foo_1416314634.0003_baa0369d" bool(false)
Output for 7.1.16
string(28) "foo_1416314634.0002_b2f0c609" bool(false)
Output for 7.1.15
string(28) "foo_1416314634.0002_6700c688" bool(false)
Output for 7.1.14
string(28) "foo_1416314634.0003_25eb87f1" bool(false)
Output for 7.1.13
string(28) "foo_1416314634.0002_18b27f3f" bool(false)
Output for 7.1.12
string(28) "foo_1416314634.0002_e1c91322" bool(false)
Output for 7.1.11
string(28) "foo_1416314634.0003_e9a54250" bool(false)
Output for 7.1.10
string(28) "foo_1416314634.0004_6e4afdad" bool(false)
Output for 7.1.9
string(28) "foo_1416314634.0002_5706b5a8" bool(false)
Output for 7.1.8
string(28) "foo_1416314634.0003_583b9eb4" bool(false)
Output for 7.1.6
string(28) "foo_1416314634.0003_3c34c4d7" bool(false)
Output for 7.1.5
string(28) "foo_1416314634.0002_036e6659" bool(false)
Output for 7.1.4
string(28) "foo_1416314634.0004_da9b27e5" bool(false)
Output for 7.1.3
string(28) "foo_1416314634.0003_1be452e5" bool(false)
Output for 7.1.2
string(28) "foo_1416314634.0002_97b6dc00" bool(false)
Output for 7.1.0
string(28) "foo_1416314634.0002_b850b4c8" bool(false)
Output for 7.0.33
string(28) "foo_1416314634.0004_4940e901" bool(false)
Output for 7.0.26, 7.0.32
string(28) "foo_1416314634.0003_37ca21af" bool(false)
Output for 7.0.31
string(28) "foo_1416314634.0003_f828fe1e" bool(false)
Output for 7.0.30
string(28) "foo_1416314634.0002_c2322a07" bool(false)
Output for 5.4.16, 7.0.29
string(28) "foo_1416314634.0002_e4bc49ca" bool(false)
Output for 7.0.28
string(28) "foo_1416314634.0002_dce51741" bool(false)
Output for 7.0.27
string(28) "foo_1416314634.0003_be35c36d" bool(false)
Output for 7.0.25
string(28) "foo_1416314634.0002_46c655c7" bool(false)
Output for 7.0.24
string(28) "foo_1416314634.0002_5886654e" bool(false)
Output for 7.0.23
string(28) "foo_1416314634.0003_b271d4d5" bool(false)
Output for 5.4.45, 7.0.22
string(28) "foo_1416314634.0002_bb1bfaf9" bool(false)
Output for 7.0.17, 7.0.21
string(28) "foo_1416314634.0002_f0cb1b3d" bool(false)
Output for 7.0.20
string(28) "foo_1416314634.0003_812b672f" bool(false)
Output for 7.0.19
string(28) "foo_1416314634.0002_7e2e62ce" bool(false)
Output for 5.6.3, 7.0.18
string(28) "foo_1416314634.0002_9fb5516f" bool(false)
Output for 7.0.15 - 7.0.16
string(28) "foo_1416314634.0002_a124373c" bool(false)
Output for 7.0.14
string(28) "foo_1416314634.0002_9058ad9c" bool(false)
Output for 7.0.13
string(28) "foo_1416314634.0003_4d909473" bool(false)
Output for 5.6.7, 7.0.12
string(28) "foo_1416314634.0002_07af5e6a" bool(false)
Output for 5.6.22, 5.6.34, 7.0.11
string(28) "foo_1416314634.0002_da6cfb0d" bool(false)
Output for 7.0.10
string(28) "foo_1416314634.0002_f455fe85" bool(false)
Output for 5.6.0, 7.0.9
string(28) "foo_1416314634.0002_4523ba5d" bool(false)
Output for 7.0.8
string(28) "foo_1416314634.0002_1dc5a856" bool(false)
Output for 7.0.7
string(28) "foo_1416314634.0003_f600fef4" bool(false)
Output for 7.0.6
string(28) "foo_1416314634.0002_5398cc44" bool(false)
Output for 7.0.5
string(28) "foo_1416314634.0003_2fa40c40" bool(false)
Output for 7.0.4
string(28) "foo_1416314634.0002_ea432fb3" bool(false)
Output for 7.0.3
string(28) "foo_1416314634.0002_f92a0035" bool(false)
Output for 7.0.2
string(28) "foo_1416314634.0002_9a3d54f2" bool(false)
Output for 5.4.29, 7.0.1
string(28) "foo_1416314634.0003_aa746d09" bool(false)
Output for 7.0.0
string(28) "foo_1416314634.0004_5b96a03b" bool(false)
Output for 5.6.40
string(28) "foo_1416314634.0002_35639ef8" bool(false)
Output for 5.6.39
string(28) "foo_1416314634.0003_73d924a2" bool(false)
Output for 5.5.24, 5.6.37 - 5.6.38
string(28) "foo_1416314634.0002_d80a6a2d" bool(false)
Output for 5.6.36
string(28) "foo_1416314634.0002_8e36eb7a" bool(false)
Output for 5.6.27, 5.6.35
string(28) "foo_1416314634.0002_3d9e2cdf" bool(false)
Output for 5.6.33
string(28) "foo_1416314634.0004_ea13494e" bool(false)
Output for 5.6.32
string(28) "foo_1416314634.0002_12ef0e3a" bool(false)
Output for 5.5.12, 5.6.31
string(28) "foo_1416314634.0002_f6632417" bool(false)
Output for 5.6.30
string(28) "foo_1416314634.0002_d557da16" bool(false)
Output for 5.6.29
string(28) "foo_1416314634.0003_a8b6c776" bool(false)
Output for 5.6.28
string(28) "foo_1416314634.0002_7a1e1e27" bool(false)
Output for 5.6.26
string(28) "foo_1416314634.0003_f6dcd5c8" bool(false)
Output for 5.6.25
string(28) "foo_1416314634.0003_b7df9b00" bool(false)
Output for 5.6.24
string(28) "foo_1416314634.0004_80b42e72" bool(false)
Output for 5.5.33, 5.6.23
string(28) "foo_1416314634.0004_be5cd863" bool(false)
Output for 5.5.34, 5.6.2, 5.6.21
string(28) "foo_1416314634.0002_a47f266e" bool(false)
Output for 5.6.20
string(28) "foo_1416314634.0005_9bf60c3e" bool(false)
Output for 5.6.19
string(28) "foo_1416314634.0002_67d845f3" bool(false)
Output for 5.6.18
string(28) "foo_1416314634.0003_21f86b59" bool(true)
Output for 5.6.17
string(28) "foo_1416314634.0002_fd7b9fb6" bool(true)
Output for 5.6.16
string(28) "foo_1416314634.0003_af6a3eab" bool(false)
Output for 5.6.15
string(28) "foo_1416314634.0002_97f8f800" bool(false)
Output for 5.4.18, 5.6.14
string(28) "foo_1416314634.0002_85604cba" bool(false)
Output for 5.6.13
string(28) "foo_1416314634.0004_cb6bf704" bool(false)
Output for 5.6.12
string(28) "foo_1416314634.0002_d60078f8" bool(false)
Output for 5.6.11
string(28) "foo_1416314634.0004_cf086bb9" bool(false)
Output for 5.6.10
string(28) "foo_1416314634.0003_176796f3" bool(false)
Output for 5.6.9
string(28) "foo_1416314634.0002_bca1fc15" bool(false)
Output for 5.6.8
string(28) "foo_1416314634.0002_a60b4c08" bool(false)
Output for 5.6.6
string(28) "foo_1416314634.0002_43397981" bool(false)
Output for 5.6.5
string(28) "foo_1416314634.0004_987b4e46" bool(false)
Output for 5.6.4
string(28) "foo_1416314634.0002_4c545442" bool(false)
Output for 5.6.1
string(28) "foo_1416314634.0002_f78bf51f" bool(false)
Output for 5.5.38
string(28) "foo_1416314634.0004_41687097" bool(false)
Output for 5.4.24, 5.5.37
string(28) "foo_1416314634.0003_5ec658b4" bool(false)
Output for 5.5.36
string(28) "foo_1416314634.0002_e5d3c5fa" bool(false)
Output for 5.4.19, 5.5.11, 5.5.35
string(28) "foo_1416314634.0002_44917b66" bool(false)
Output for 5.4.31, 5.5.10, 5.5.32
string(28) "foo_1416314634.0003_7a898d3b" bool(false)
Output for 5.5.31
string(28) "foo_1416314634.0003_6e517b60" bool(false)
Output for 5.5.30
string(28) "foo_1416314634.0003_1c4a1d7a" bool(false)
Output for 5.5.29
string(28) "foo_1416314634.0002_38d9f2d2" bool(false)
Output for 5.4.26, 5.5.28
string(28) "foo_1416314634.0002_1a938109" bool(false)
Output for 5.5.27
string(28) "foo_1416314634.0004_325ff63d" bool(false)
Output for 5.5.26
string(28) "foo_1416314634.0002_e7c2d5b8" bool(false)
Output for 5.4.6, 5.5.18, 5.5.25
string(28) "foo_1416314634.0002_3fe27b84" bool(false)
Output for 5.5.23
string(28) "foo_1416314634.0003_2303a7bd" bool(false)
Output for 5.5.22
string(28) "foo_1416314634.0004_04d39752" bool(false)
Output for 5.5.21
string(28) "foo_1416314634.0003_dd37b31d" bool(false)
Output for 5.5.20
string(28) "foo_1416314634.0004_d118c8e1" bool(false)
Output for 5.5.19
string(28) "foo_1416314634.0003_af613898" bool(false)
Output for 5.5.17
string(28) "foo_1416314634.0003_98646fe5" bool(false)
Output for 5.5.16
string(28) "foo_1416314634.0003_fefbf212" bool(false)
Output for 5.5.15
string(28) "foo_1416314634.0002_b5296145" bool(false)
Output for 5.4.28, 5.5.14
string(28) "foo_1416314634.0002_4eda8631" bool(false)
Output for 5.5.13
string(28) "foo_1416314634.0003_0d03848a" bool(true)
Output for 5.5.9
string(28) "foo_1416314634.0003_ced4bae5" bool(false)
Output for 5.5.8
string(28) "foo_1416314634.0002_6e996029" bool(false)
Output for 5.5.7
string(28) "foo_1416314634.0003_2bc09de3" bool(false)
Output for 5.5.6
string(28) "foo_1416314634.0003_198f4100" bool(false)
Output for 5.5.5
string(28) "foo_1416314634.0003_4090f818" bool(false)
Output for 5.5.4
string(28) "foo_1416314634.0003_192eb441" bool(false)
Output for 5.5.3
string(28) "foo_1416314634.0004_037909e8" bool(false)
Output for 5.5.2
string(28) "foo_1416314634.0003_94a56b4e" bool(false)
Output for 5.5.1
string(28) "foo_1416314634.0004_3f2dce3c" bool(false)
Output for 5.5.0
string(28) "foo_1416314634.0004_09a32759" bool(false)
Output for 5.4.44
string(28) "foo_1416314634.0003_531d82af" bool(false)
Output for 5.4.43
string(28) "foo_1416314634.0003_953496a7" bool(false)
Output for 5.4.30, 5.4.42
string(28) "foo_1416314634.0003_cf086bb9" bool(false)
Output for 5.4.41
string(28) "foo_1416314634.0002_8e681e5c" bool(false)
Output for 5.4.40
string(28) "foo_1416314634.0004_d8810f19" bool(false)
Output for 5.4.39
string(28) "foo_1416314634.0003_5356fcd0" bool(false)
Output for 5.4.38
string(28) "foo_1416314634.0004_9a16e330" bool(false)
Output for 5.4.37
string(28) "foo_1416314634.0002_2fa43ef7" bool(false)
Output for 5.4.36
string(28) "foo_1416314634.0003_b35a694b" bool(false)
Output for 5.4.35
string(28) "foo_1416314634.0004_8766e8dd" bool(false)
Output for 5.4.34
string(28) "foo_1416314634.0003_e122a109" bool(false)
Output for 5.4.33
string(28) "foo_1416314634.0003_46fe739f" bool(false)
Output for 5.4.32
string(28) "foo_1416314634.0004_3a6430c4" bool(false)
Output for 5.4.27
string(28) "foo_1416314634.0003_b79830ef" bool(false)
Output for 5.4.25
string(28) "foo_1416314634.0003_10d093dc" bool(false)
Output for 5.4.23
string(28) "foo_1416314634.0004_0bd857a6" bool(false)
Output for 5.4.22
string(28) "foo_1416314634.0003_04dd34b9" bool(false)
Output for 5.4.21
string(28) "foo_1416314634.0003_8716cfb3" bool(false)
Output for 5.4.20
string(28) "foo_1416314634.0005_a634e70a" bool(false)
Output for 5.4.17
string(28) "foo_1416314634.0002_99ce51a2" bool(false)
Output for 5.4.15
string(28) "foo_1416314634.0002_a49b8b39" bool(false)
Output for 5.4.14
string(28) "foo_1416314634.0003_ed2d382c" bool(false)
Output for 5.4.13
string(28) "foo_1416314634.0004_cd148d57" bool(false)
Output for 5.4.12
string(28) "foo_1416314634.0003_61d4cfd0" bool(false)
Output for 5.4.11
string(28) "foo_1416314634.0004_6adc4552" bool(false)
Output for 5.4.10
string(28) "foo_1416314634.0004_55c00779" bool(false)
Output for 5.4.9
string(28) "foo_1416314634.0003_4bbc1d45" bool(false)
Output for 5.4.8
string(28) "foo_1416314634.0003_21d16908" bool(false)
Output for 5.4.7
string(28) "foo_1416314634.0003_eaa2b817" bool(false)
Output for 5.4.5
string(28) "foo_1416314634.0004_daa1cf01" bool(false)
Output for 5.4.4
string(28) "foo_1416314634.0003_e49f6c4c" bool(false)
Output for 5.4.3
string(28) "foo_1416314634.0002_359e827d" bool(false)
Output for 5.4.2
string(28) "foo_1416314634.0002_a5b06122" bool(false)
Output for 5.4.1
string(28) "foo_1416314634.0004_dfd19a3d" bool(false)
Output for 5.4.0
string(28) "foo_1416314634.0004_a4502bf4" bool(false)
Output for 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/hdMvm on line 49
Process exited with code 255.
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Parse error: syntax error, unexpected ':' in /in/hdMvm on line 11
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected ':' in /in/hdMvm on line 11
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_CLASS in /in/hdMvm 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_CLASS in /in/hdMvm on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/hdMvm on line 3
Process exited with code 255.

preferences:
239.15 ms | 401 KiB | 325 Q