3v4l.org

run code in 300+ PHP versions simultaneously
<?php class C { public ?int $v = 123; } $x = new C; unset($x->v); $y = new C; $y->v = null; function propertyWasUnset($object, $propertyName) { try { $object->{$propertyName}; return true; } catch (\Error $e) { return false; } } var_dump(propertyWasUnset($x, 'v')); var_dump(propertyWasUnset($y, 'v'));

preferences:
26.21 ms | 402 KiB | 5 Q