3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class CommandId { private $name; private $timestamp; public function __construct($name) { $this->name = (string) $name; $this->timestamp = microtime(); } public static function fromString($anId) { $parts = explode('_', $anId); $id = new static($parts[0]); $id->timestamp = (int) $parts[1]; return $id; } public function name() { return $this->name; } public function timestamp() { return $this->timestamp; } public function __toString() { return "{$this->name}_{$this->timestamp}"; } } echo CommandId::fromString('Foo_' . microtime());

preferences:
46.82 ms | 402 KiB | 5 Q