3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Coalescing { protected $attributes = [ 'attribute1' => 'value1', ]; public function __get($name) { print "GET\n"; if (array_key_exists($name, $this->attributes)) { return $this->attributes[$name]; } trigger_error("Property $name does not exist"); return null; } public function __isset($name) { print "ISSET\n"; return array_key_exists($name, $this->attributes); } } $coal = new Coalescing(); var_dump($coal->attribute1 ?? 'default'); var_dump($coal->attribute2 ?? 'default');

preferences:
31.32 ms | 402 KiB | 5 Q