3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Articulo { public function __construct( public readonly string $id, private string $nombre, private float $precioBase ) {} public function getNombre(): string { return $this->nombre; } public function getPrecio(): float { return $this->precioBase; } public function modificarPrecio(float $nuevoPrecio): void { if ($nuevoPrecio <= 0) { throw new Exception("Error: El nuevo precio debe ser mayor a 0."); } $this->precioBase = $nuevoPrecio; } }
Output for 8.2.31 - 8.2.33, 8.3.0 - 8.3.33, 8.4.1 - 8.4.24, 8.5.0 - 8.5.9

preferences:
33.28 ms | 774 KiB | 4 Q