3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public string $bar = 'a'; public ?string $baz = null; public function __construct(public readonly ?string $x = null) { } } $foo = new Foo(); $fooSerialized = 'O:3:"Foo":1:{s:3:"bar";s:1:"a";}a'; $fooUnserialized = unserialize($fooSerialized); var_dump($fooUnserialized->bar); // works because exists in serialized string var_dump($fooUnserialized->baz); // works because regular typed property, even if not existing in serialized string var_dump($fooUnserialized->x); // Doesn't work
Output for git.master, git.master_jit
Warning: unserialize(): Extra data starting at offset 32 of 33 bytes in /in/4d6XG on line 14 string(1) "a" NULL Fatal error: Uncaught Error: Typed property Foo::$x must not be accessed before initialization in /in/4d6XG:18 Stack trace: #0 {main} thrown in /in/4d6XG on line 18
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
32.86 ms | 405 KiB | 5 Q