3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class TimeCurrency { public static function createFromString(string $formatted): self { if (!preg_match('/^(\d{4}):(\d{2}):(\d{1}):(\d{2}):(\d{2})$/', $formatted, $matches)) { throw new \InvalidArgumentException('Invalid currency format.'); } return new self(...array_slice($matches, 1)); } /** @var int */ private $year; /** @var int */ private $weekNumber; /** @var int */ private $day; /** @var int */ private $hour; /** @var int */ private $minute; public function __construct(int $year, int $weekNumber, int $day, int $hour, int $minute) { $this->year = $year; $this->weekNumber = $weekNumber; $this->day = $day; $this->hour = $hour; $this->minute = $minute; } public function addYears(int $addedYears): void { $this->year += $addedYears; } public function __toString(): string { return sprintf('%04d:%02d:%d:%02d:%02d', $this->year, $this->weekNumber, $this->day, $this->hour, $this->minute); } } // Example usage $currency = TimeCurrency::createFromString('2010:21:1:23:21'); $currency->addYears(4); echo $currency;
Output for git.master, git.master_jit, rfc.property-hooks
2014:21:1:23:21

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
42.66 ms | 1472 KiB | 4 Q