3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyClass { public $variable; public function publicMethod() { print_r($this); } public function example() { // this resolves to "publicMethod of MyClass" // there is an instance of MyClass in the scope so it is used - the method is not called statically MyClass::publicMethod(); } } $object = new MyClass(); $object->variable = 123; $object->example();
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
MyClass Object ( [variable] => 123 )

preferences:
53.91 ms | 402 KiB | 62 Q