- var_dump: documentation ( source)
<?php
class foo
{
private $x = 1;
}
function & getProp(foo $x)
{
$prop = new ReflectionProperty($x, 'x');
$prop->setAccessible(true);
$p = &$x->x;
// $prop->setAccessible(false);
return $p;
}
$x = new foo;
$y = getProp($x);
var_dump($x);
$y = 2;
var_dump($x);