- var_dump: documentation ( source)
<?php
class Test
{
protected $protectedVariable;
public function __construct()
{
$this->protectedVariable = 'this belongs to test class';
}
}
function showCase($callback)
{
return $callback(5);
}
$x = showCase(new class ($x) extends Test {
public $holder;
public $publicVar;
public function __construct($classArg) {
parent::__construct();
$this->holder = $classArg;
}
public function multiplyByNo($multiplier)
{
return $this->holder * $multiplier;
}
public function getParentVar()
{
$this->publicVar = $this->protectedVariable;
return $this->protectedVariable;
}
});
var_dump($x->multiplyByNo(10));
var_dump($x->getParentVar());
var_dump($x);