3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Entity { private Decimal $subtotal; public function getSubtotal() { return $this->subtotal; } public function setSubtotal(Decimal $value) { $this->subtotal = $value; return $this; } } class Decimal { private string $value; public function __construct(string $value) { $this->value = $value; } public function getValue() { return $this->value; } public function toFixed(int $scale): Decimal { // rough example for adjusting precision - do not use return new self(bcadd($this->value, '0', $scale)); } } //////////////// $entity = new Entity(); $entity->setSubtotal((new Decimal('1337.987654321'))->toFixed(4)); echo $entity->getSubtotal()->getValue();
Output for git.master, git.master_jit, rfc.property-hooks
1337.9876

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:
51.55 ms | 1250 KiB | 4 Q