3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait Singleton { private static ?object $instance = null; public static function GetInstance(): object { // Reflection better here for Dependency Injection into the instance return self::$instance ?? (self::$instance = new self()); } public function __set(string $property, string $value) { $this->{$property} = $value; } public function __get(string $property): mixed { return $this->{$property} ?? null; } protected function __construct() {} private function __clone() {} } class User { use Singleton; protected function __construct() { // Change this to the select inner join query foreach(['id' => 1, 'column' => 'test', 'points' => 3] as $column => $value) $this->$column = $value; } public function save(): mixed { // Change this to an update query return get_object_vars($this); } } User::getInstance()->points = 5; // Dynamically change values var_dump(User::getInstance()->save()); // Then update
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Creation of dynamic property User::$id is deprecated in /in/3WrMs on line 13 Deprecated: Creation of dynamic property User::$column is deprecated in /in/3WrMs on line 13 Deprecated: Creation of dynamic property User::$points is deprecated in /in/3WrMs on line 13 array(3) { ["id"]=> string(1) "1" ["column"]=> string(4) "test" ["points"]=> int(5) }

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:
115.16 ms | 406 KiB | 5 Q