3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Outside { private $private = 'You should be able to see me'; public function getAnon() { return new class($this) { private $outside; public function __construct($outside) { $this->outside = $outside; } public function getPrivateOfOutside() { return $this->outside->private; } }; } } $foo = new Outside(); var_dump($foo->getAnon()->getPrivateOfOutside());

preferences:
27.14 ms | 404 KiB | 5 Q