3v4l.org

run code in 500+ PHP versions simultaneously
<?php class BlogData { public function __construct( public readonly string $title = 'Readonly-свойства', ) {} } $a = new BlogData(); $b = clone $a; var_dump($b);
Output for 8.1.2 - 8.1.34, 8.2.0 - 8.2.36, 8.3.0 - 8.3.37, 8.4.1 - 8.4.28, 8.5.0 - 8.5.12
object(BlogData)#2 (1) { ["title"]=> string(25) "Readonly-свойства" }
Output for 8.0.0 - 8.0.10
Parse error: syntax error, unexpected identifier "string", expecting variable in /in/iH8qW on line 8
Process exited with code 255.
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.23
Parse error: syntax error, unexpected 'public' (T_PUBLIC), expecting variable (T_VARIABLE) in /in/iH8qW on line 8
Process exited with code 255.

preferences:
29.16 ms | 1170 KiB | 6 Q