3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait T { public static int $sp = 1; public static function sm(): int { return 2; } // public const C = 3; } var_dump(T::$sp); var_dump(T::sm()); // var_dump(T::C);
Output for 8.1rc1 - rc2
Deprecated: Accessing static trait property T::$sp is deprecated, it should only be accessed on a class using the trait in /in/eGlYm on line 9 int(1) Deprecated: Calling static trait method T::sm is deprecated, it should only be called on a class using the trait in /in/eGlYm on line 10 int(2)
Output for 7.4.0 - 7.4.23, 8.0.0 - 8.0.11
int(1) int(2)
Output for 7.3.0 - 7.3.30
Parse error: syntax error, unexpected 'int' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in /in/eGlYm on line 4
Process exited with code 255.

preferences:
44.15 ms | 461 KiB | 5 Q