- var_dump: documentation ( source)
<?php
class Test
{
private $foo;
public function __construct($foo)
{
$this->foo = $foo;
}
private function bar()
{
echo 'Доступ к закрытому методу.';
}
public function baz(Test $other)
{
// Мы можем изменить закрытое свойство:
$other->foo = 'hello';
var_dump($other->foo);
// Мы также можем вызвать закрытый метод:
$other->bar();
}
}
$test = new Test('test');
$test->baz(new Test('other'));
?>