3v4l.org

run code in 300+ PHP versions simultaneously
<?php class User { public string $name = ""; public string $password = ""; public int $admin = 0; public string $fullName = ""; public function __construct(string $name, string $password, int $admin) { $this->name = $name; $this->password= $password; $this->admin = $admin; } public function __wakeup() { $this->fullName = $this->name . $this->password; } } $user_test = new User("Sebastian", "Password", 1); var_dump($user_test); var_dump(serialize($user_test)); $other_user = unserialize('O:4:"User":3:{s:4:"name";s:9:"Sebastian";s:8:"password";s:8:"Password";s:5:"admin";i:2;}'); var_dump($other_user);
Output for 7.4.0 - 7.4.21, 8.0.0 - 8.0.8
object(User)#1 (4) { ["name"]=> string(9) "Sebastian" ["password"]=> string(8) "Password" ["admin"]=> int(1) ["fullName"]=> string(0) "" } string(110) "O:4:"User":4:{s:4:"name";s:9:"Sebastian";s:8:"password";s:8:"Password";s:5:"admin";i:1;s:8:"fullName";s:0:"";}" object(User)#2 (4) { ["name"]=> string(9) "Sebastian" ["password"]=> string(8) "Password" ["admin"]=> int(2) ["fullName"]=> string(17) "SebastianPassword" }
Output for 7.3.0 - 7.3.29
Parse error: syntax error, unexpected 'string' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in /in/N3a1U on line 5
Process exited with code 255.

preferences:
92.99 ms | 460 KiB | 5 Q