- property_exists: documentation ( source)
- var_dump: documentation ( source)
<?php
class C implements ArrayAccess
{
public $data = array(
"foo" => null
);
public function offsetExists($offset): bool
{
return array_key_exists((string)$offset, $this->data);
}
public function offsetGet($offset)
{
return $this->data[$offset];
}
public function offsetSet($offset, $value): void
{
$this->data[$offset] = $value;
}
public function offsetUnset($offset): void
{
unset($this->data[$offset]);
}
}
$o = new C();
var_dump(isset($o['foo']));
var_dump(property_exists($o, 'foo'));
var_dump(array_key_exists('foo', $o));
var_dump(array_key_exists('foo', ['foo' => null]));