3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private int $foo; private int $bar = 1; public function propertyInitialized($name): bool { return property_exists($this, $name) && isset($this->$name); } } $foo = new foo; var_dump($foo->propertyInitialized('foo'), $foo->propertyInitialized('bar'));

preferences:
29.64 ms | 402 KiB | 5 Q