3v4l.org

run code in 300+ PHP versions simultaneously
<?php class a { function foo() { echo __METHOD__ . PHP_EOL; } } class b extends a {} class c extends b { function bar() { $this::foo(); $this->foo(); a::foo(); b::foo(); c::foo(); d::foo(); static::foo(); self::foo(); parent::foo(); } } class d extends c {} (new c)->bar();
Output for 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
a::foo a::foo a::foo a::foo a::foo Fatal error: Uncaught Error: Non-static method a::foo() cannot be called statically in /in/j04vj:17 Stack trace: #0 /in/j04vj(26): c->bar() #1 {main} thrown in /in/j04vj on line 17
Process exited with code 255.

preferences:
47.84 ms | 867 KiB | 4 Q