- var_dump: documentation ( source)
- unserialize: documentation ( source)
- serialize: documentation ( source)
<?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);