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 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.
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 8.1.2 - 8.1.34, 8.2.0 - 8.2.34, 8.3.0 - 8.3.35, 8.4.1 - 8.4.26, 8.5.0 - 8.5.11
object(BlogData)#2 (1) { ["title"]=> string(25) "Readonly-свойства" }

preferences:
35.56 ms | 1143 KiB | 11 Q