- Output for 8.1.13
- Fatal error: Uncaught Error: Cannot initialize readonly property Foo::$foo from global scope in /in/ld621:12
Stack trace:
#0 {main}
thrown in /in/ld621 on line 12
Process exited with code 255.
<?php
class Foo {
readonly int $foo;
public function __set($key, $value)
{
echo "__set called with {$value}\n";
}
}
$f = new Foo;
$f->foo = 43;