- property_exists: documentation ( source)
- var_dump: documentation ( source)
<?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'));