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 __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 8.0.0 - 8.0.3
Parse error: syntax error, unexpected token "(", expecting variable in /in/eA90K on line 17
Process exited with code 255.
Output for 7.4.0 - 7.4.16
Parse error: syntax error, unexpected '(', expecting variable (T_VARIABLE) in /in/eA90K on line 17
Process exited with code 255.
Output for 7.3.0 - 7.3.28
Parse error: syntax error, unexpected 'string' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in /in/eA90K on line 5
Process exited with code 255.

preferences:
364.32 ms | 458 KiB | 5 Q