3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public static function A() { echo 'direct owner: '.__CLASS__."\n"; echo 'called as part of: '.self::class."\n"; echo 'called by instance of: '.static::class."\n"; } } class B extends A { } class C { function __construct() { B::A(); } } new C();
Output for 8.1.23 - 8.1.28, 8.2.10 - 8.2.18, 8.3.0 - 8.3.6
direct owner: A called as part of: A called by instance of: B
Output for 7.0.0 - 7.0.2
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; A has a deprecated constructor in /in/kbmG1 on line 3 Fatal error: Constructor A::A() cannot be static in /in/kbmG1 on line 3
Process exited with code 255.
Output for 5.5.24 - 5.5.31, 5.6.8 - 5.6.17
Fatal error: Constructor A::A() cannot be static in /in/kbmG1 on line 9
Process exited with code 255.

preferences:
86.96 ms | 402 KiB | 48 Q