- print_r: documentation ( source)
<?php
class MyClass
{
private $string;
private $array;
public function __set($attribute, $value)
{
$this->$attribute = $value;
}
public function __get($attribute)
{
if (isset($attribute))
{
return $this->$attribute;
}
}
}
$obg = new MyClass();
$obg->string = 'Hey it works!';
$obg->array = new ArrayObject(['This works', 'too!']);
$obg->array['key'] = "This will throw 'Indirect modification of overloaded property MyClass::\$array has no effect'";
print_r($obg->array->getArrayCopy());