3v4l.org

run code in 300+ 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
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.30, 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:
193.79 ms | 1395 KiB | 72 Q