3v4l.org

run code in 500+ PHP versions simultaneously
<?php class A { private object $secret; public object $container { get { $obj = new stdClass(); $obj->test = random_bytes(7); return $obj; } set (object $val){ $this->secret = $val; } } public function getSecret() { return $this->secret; } } $a = new A(); var_dump($a->container); var_dump($a->container); $a->container = new stdClass(); var_dump($a->container); var_dump($a->getSecret());
Output for 8.4.14
object(stdClass)#2 (1) { ["test"]=> string(7) " ��a�H" } object(stdClass)#2 (1) { ["test"]=> string(7) "�T��̙" } object(stdClass)#3 (1) { ["test"]=> string(7) "<e�� �" } object(stdClass)#2 (0) { }
Output for 8.3.5
Parse error: syntax error, unexpected token "{", expecting "," or ";" in /in/SXiru on line 7
Process exited with code 255.

preferences:
46.82 ms | 493 KiB | 3 Q