3v4l.org

run code in 300+ PHP versions simultaneously
<?php class B { public string $hello = "world"; } class Test { public string $test = "B"; public function test() { return "B"; } } $class = new Test(); $test = new $class->test; echo $test->hello;
Output for 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
world
Output for 7.4.33
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Test has a deprecated constructor in /in/mcSNH on line 7 world

preferences:
68.45 ms | 407 KiB | 5 Q