3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Cookpedia; class Entry { private $hydrated = false; private $data = [ 'id' => 0, 'title' => null, 'latin_title' => null, 'category' => 0, 'calories' => 0, 'proteins' => 0, 'fats' => 0, 'carbohydrates' => 0, 'description' => null, 'tags' => [], 'measures' => [], ]; public function hydrate(): Entity { return new Entity(...array_values($this->data)); } } class Entity { public function __construct(int $id, ?string $title, ?string $latinTitle, int $category, int $calories, int $proteins, int $fats, int $carbohydrates, ?string $description, array $tags, array $measures) { $this->carbohydrates = $carbohydrates; } } $entity = (new Entry())->hydrate(); var_dump($entity);
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Creation of dynamic property Cookpedia\Entity::$carbohydrates is deprecated in /in/YCYLP on line 34 object(Cookpedia\Entity)#2 (1) { ["carbohydrates"]=> int(0) }

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:
93.98 ms | 401 KiB | 8 Q