3v4l.org

run code in 200+ PHP versions simultaneously
<?php class PriceList { /** * @var float[] */ protected $data = []; public function addPrice(float $price): void { $this->data[] = $price; } /** * @return float[] Array of prices */ public function all(): array { return $this->data; } } $priceList = new PriceList(); $priceList->addPrice(29.99); $priceList->addPrice(89); $priceList->addPrice(199); print_r($priceList->all());
Output for 7.1.25 - 7.4.0
Array ( [0] => 29.99 [1] => 89 [2] => 199 )