3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Product { private string $title; private string $description; private int $price; private string $currency; private string $category; private string $brand; private array $options; /** * @param string $title * @param string $description * @param int $price * @param string $currency * @param string $category * @param string $brand * @param array $options */ public function __construct(string $title, string $description, int $price, string $currency, string $category, string $brand, array $options) { $this->title = $title; $this->description = $description; $this->price = $price; $this->currency = $currency; $this->category = $category; $this->brand = $brand; $this->options = $options; } /** * @return string */ public function getTitle(): string { return $this->title; } /** * @param string $title */ public function setTitle(string $title): void { $this->title = $title; } /** * @return string */ public function getDescription(): string { return $this->description; } /** * @param string $description */ public function setDescription(string $description): void { $this->description = $description; } /** * @return int */ public function getPrice(): int { return $this->price; } /** * @param int $price */ public function setPrice(int $price): void { $this->price = $price; } /** * @return string */ public function getCurrency(): string { return $this->currency; } /** * @param string $currency */ public function setCurrency(string $currency): void { $this->currency = $currency; } /** * @return string */ public function getCategory(): string { return $this->category; } /** * @param string $category */ public function setCategory(string $category): void { $this->category = $category; } /** * @return string */ public function getBrand(): string { return $this->brand; } /** * @param string $brand */ public function setBrand(string $brand): void { $this->brand = $brand; } /** * @return array */ public function getOptions(): array { return $this->options; } /** * @param array $options */ public function setOptions(array $options): void { $this->options = $options; } } class Option { private string $title; private string $description; private int $price; private array $items; /** * @param string $title * @param string $description * @param int $price * @param array $items */ public function __construct(string $title, string $description, int $price, array $items) { $this->title = $title; $this->description = $description; $this->price = $price; $this->items = $items; } /** * @param string $title */ public function setTitle(string $title): void { $this->title = $title; } /** * @param string $description */ public function setDescription(string $description): void { $this->description = $description; } /** * @param int $price */ public function setPrice(int $price): void { $this->price = $price; } /** * @param array $items */ public function setItems(array $items): void { $this->items = $items; } } class OptionItem { private string $title; private string $description; private int $price; /** * @param string $title * @param string $description * @param int $price */ public function __construct(string $title, string $description, int $price) { $this->title = $title; $this->description = $description; $this->price = $price; } /** * @param string $title */ public function setTitle(string $title): void { $this->title = $title; } /** * @param string $description */ public function setDescription(string $description): void { $this->description = $description; } /** * @param int $price */ public function setPrice(int $price): void { $this->price = $price; } } $product = []; for ($k = 0; $k <= 100; $k++) { $options = []; for ($j = 0; $j <= 10; $j++) { $optionItems = []; for ($i = 0; $i <= 100; $i++) { $optionItem = new OptionItem(title: 'OptionItem' . $i, description: 'OptionItem ' . $i . ' Description', price: random_int(1000, 10000)); $optionItems[] = $optionItem; } $option = new Option(title: 'Option' . $j, description: 'Option ' . $j . ' Description', price: random_int(1000, 10000), items: $optionItems); $options[] = $option; } $product[] = new Product(title: 'Product' . $k, description: 'Product ' . $k . ' Description', price: random_int(1000, 10000), currency: 'USD', category: 'Category' . $k, brand: 'Brand' . $k, options: $options); }
Output for 8.2.0 - 8.2.26, 8.3.0 - 8.3.14, 8.4.1

preferences:
60.54 ms | 405 KiB | 5 Q