- print_r: documentation ( source)
<?php
class Foo
{
public int $a;
protected int $b;
private int $c;
public function __construct()
{
$this->a = 2;
$this->b = 3;
$this->c = 4;
}
}
$foo = new Foo();
$arr = (array) $foo;
$o = (object) $arr; // should emit a warning as protected properties are renamed
print_r($foo);
print_r($arr);
print_r($o);
$o->b = 10; // because this creates new property!
print_r($o);