3v4l.org

run code in 300+ PHP versions simultaneously
<?php class FooBar { public function __construct() { echo self::class; } } $bar = new FooBar; echo $bar::class;
Output for 8.1.23 - 8.1.28, 8.2.10 - 8.2.18, 8.3.0 - 8.3.6
FooBarFooBar
Output for 7.0.0 - 7.0.1
Fatal error: Dynamic class names are not allowed in compile-time ::class fetch in /in/GJ0pN on line 13
Process exited with code 255.
Output for 5.5.24 - 5.5.30, 5.6.8 - 5.6.16
Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /in/GJ0pN on line 13
Process exited with code 255.

preferences:
62.29 ms | 402 KiB | 45 Q