- var_dump: documentation ( source)
<?php
class Foo {
protected $bar = 'foo';
}
$foo = new Foo();
$reflection = (new ReflectionObject($foo))->getProperty('bar');
$reflection->setAccessible(true);
$reflection->setValue('baz');
$reflection->setAccessible(false);
var_dump($foo);