- var_dump: documentation ( source)
- error_reporting: documentation ( source)
<?php
error_reporting(E_ALL);
class MyArray implements ArrayAccess
{
public $value;
public function __construct($value = null)
{
$this->value = $value;
}
public function &offsetGet($offset)
{
var_dump(__METHOD__);
if (!isset($this->value[$offset])) {
$this->value[$offset] = null;
}
return $this->value[$offset];
}
public function offsetExists($offset)
{
var_dump(__METHOD__);
return isset($this->value[$offset]);
}
public function offsetSet($offset, $value)
{
var_dump(__METHOD__);
$this->value[$offset] = $value;
}
public function offsetUnset($offset)
{
var_dump(__METHOD__);
$this->value[$offset] = null;
}
}
$record = new MyArray([
'foo' => [
'bar' => 'baz'
]
]);
var_dump(isset($record['foo']['bar']));
var_dump(isset($record['hello']['world']));